LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help renaming files (https://www.linuxquestions.org/questions/linux-newbie-8/help-renaming-files-573134/)

balistic 07-29-2007 07:36 AM

help renaming files
 
hey i was hoping someone here could help me. i need to rename all files in a directory that contain a ? symbol to be renamed to add a .txt extension on the end (doesnt have to replace the current one), if anyone can help me by telling me what command to use i would be very happy :)

rtspitz 07-29-2007 07:44 AM

Code:

find ./ -maxdepth 1 -iname "*\?*" -exec rename {} {}.txt {} \;
- maxdepth 1 limits it to the current directory ( = not recursive)

balistic 07-29-2007 07:58 AM

Code:

find ./ -maxdepth 1 -iname "*\?*" -exec rename {} {}.torrent {} \;
spits out.
find: rename: No such file or directory
find: rename: No such file or directory
find: rename: No such file or directory
find: rename: No such file or directory

rename doesnt work :( is there a way to do it using the mv command or something?

pixellany 07-29-2007 07:58 AM

Code:

for name in `ls|grep ?`; do mv $name $name.txt; done
Note that ls|grep ? is enclosed in "back-tics", not single quotes.....

balistic 07-29-2007 08:04 AM

Works, thanks so much and sorry about the double post before :)


All times are GMT -5. The time now is 07:06 AM.