Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | None | 0 0
  1. ====================================================================================
  2. HACKY SOLUTION TO APPENDING AN "_" to ALL FILES IN PARENT DIRECTORY AND ITS CHILDREN
  3. ====================================================================================
  4.  
  5. 1. Go to parent directory. Run the following line; it will generate a script file that you can run after to append an "_" before the file extension.
  6.  
  7. % find -iname '*.*' | while read f; do f=${f:2} ; echo mv \"$f\" \"${f/./_.}\"; done > rename.sh
  8.  
  9. 2. Change permissions on your rename.sh file.
  10.  
  11. % chmod u+x rename.sh
  12.  
  13. 3. Run in parent directory.
  14.  
  15. % ./rename.sh
  16.  
  17. 4. Do note that you will get the following error:
  18. % mv: cannot stat ‘’: No such file or directory
  19.  
  20. This is because you do not have an empty file with an empty name. Otherwise, everything should be a-ok.
  21.  
  22. NOTE: Your script file will also have an "_" appended too.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement