Skip to content

Instantly share code, notes, and snippets.

@banderson623
Last active December 18, 2015 23:19
Show Gist options
  • Save banderson623/5860922 to your computer and use it in GitHub Desktop.
Save banderson623/5860922 to your computer and use it in GitHub Desktop.
Oh crap! Many zero sized files after copying from remote server, over vpn, through virtual machine to my iMac :( Command line + ruby to the rescue!
find . -type f -size 0 > bad_files.txt
# Read files in as a big string....
BASE_PATH = File.dirname(__FILE__)
NEW_PLACE = File.join(BASE_PATH,'..', "forVideo")
`mkdir -p "#{NEW_PLACE}"`
# puts files.split.inspect;
files = files.split("\n").map{|f| f.chomp}
files.each do |f|
if(f.length > 0)
globby = "#{BASE_PATH}/**/#{f}"
puts globby
results = Dir.glob(globby)
results.each do |this_file|
`cp -a "#{this_file}" "#{File.join(NEW_PLACE,File.basename(this_file))}"`
end
puts result.inspect
exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment