I've got this script

for file in /folder1/folder2/*; do mv "${file}" "${file//\[Free]/}"; done

And I'd like for it to: Search all subfolders in folder1 and folder 2. Pull from a list rather than just one word "free".

Any help would be much appreciated. :)


Without knowing what exactly you are trying to do here, it looks like you are wanting to find all files with a certain name, and rename them using the move command and append the old name with the word from the list. Please let me know if I am misunderstanding as it looks like you may also be trying to replace part of the name.

An example of current file location and name, and desired location and filename would help.

In the meantime this may get you what you need.

# Iterates through a text file
while read WORDLIST;
    # do stuff
    do for file in /*/*/; mv "${file}" "${file}${WORDLIST}"; 

done < <Path to WORDLIST>
  • @Orophix please mark my answer as the solution if it solves your problem. – ColonelMeow Aug 5 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.