Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hmm, yet another question for the coders, please ? ^_^
- My "previously current" renaming shell relied on this line, which was annoyingly making committing mistakes SUPER easy, for instance :
- mv $file ${file%.zip_\(English\).zip}_.zip
- Using that script led me to making minor mistakes, there were occasional strings combos that I hadn't imagined breaking everything... You can picture the loss of time - I blame nobody but me, of course.
- And then I found this PERFECTLY SIMPLE replacement script, with the replacement arguments in the command line :
- (source : http://superuser.com/questions/508731/find-and-replace-string-in-filenames )
- It even allows single quotes, no more escaping or white spaces hell ! YAY.
- #!/bin/bash
- (( $# != 2 )) && exit 1
- for f in *.zip; do
- newf="${f//$1/$2}"
- if [[ $f != $newf ]]; then
- mv "$f" "$newf"
- fi
- done
- Running it :
- ./replacestr 'original text' 'new text'
- Now, I wanted to combine it with my idea, a .txt file containing the list of the only files that I want to rename.
- After all, it worked with the previous script :
- #!/bin/bash
- for file in *.zip
- do
- mv $file ${file%_\(English\).zip}__\(English\).zip
- done
- Running it :
- cat fixzips-list.txt | xargs ./rename
- I wanted to do an adaptation of the same with the new renaming script :
- cat fixzips-list.txt | xargs ./replacestr '(www.hentai' '(www.TROLOLOL'
- ... except that, this time, it didn't work, the renaming wasn't done.
- Please, do you see what kind of option I might have missed ?
- I don't think a {} should be added here, but, I might be mistaken... Ah well, I don't know ^^
- Thanks if you can help ! :)
Add Comment
Please, Sign In to add comment