Attempting to rename a bunch of files.
I can rename any instances of foo with bar in the current directory with:
ls . | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh
What can I add to make it recursive?
Edit/My solution
I don't know/understand this shell type stuff so I did it with some (pretty dirty) Ruby:
5.times do
Dir["**/*"].each do |f|
file_name = File.absolute_path f
should_rename = file_name.include? "yolo"
new_file_name = file_name.gsub("yolo", "#{@project_name}")
File.rename(f, new_file_name) if (should_rename and File.exists? f)
end
end
find . -name "*.java" -exec rename 's|\.java|\.txt|' {} +
– Thieve