copying folder and changing extension of files in it?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
copying folder and changing extension of files in it?
IM trying to figure out the command I would use to copy contents of a folder and change the extension of the files within the folders.For example..I have main folder.. Folder A..in that folder are folders..folder 1,folder 2,folder 3,etc..and in each folder are files.I need to change the extensions of the files from .ewav to .wav..and keep the folder structure.
To rename your files with '.ewav' extension to files with '.wav' extension:
rename .ewav .wav *.ewav
This will work in the directory in which you run the command. I don't understand what you are trying to do with the copy command, copy what to where?? If you need to rename files with this extension in multiple folders?? Not sure how you would do that with a single command.
Well..Im getting closer to figuring it out..trying different variations of commands..hers a test folder of what im trying to do..maybe someone else knows how to get the rest of the way..I figured out how to copy folder and keep folder structure intact..just having issue with renaming the files to just change there extension..
Code:
strat@debian:~$ ls -R pack
pack:
[SP] Engl Pro 4x12 V30 [SP] Mesa Oversized 4x12 V30
[SP] Framus 4x12 V30 [SP] Mesa Trad 4x12 V30
[SP] Marshall 1960A 4x12 V30 + G12 (XP)
pack/[SP] Engl Pro 4x12 V30:
Engl Pro 4x12 V30 SM57 Between 01.wav Engl Pro 4x12 V30 SM57 New 03.wav
Engl Pro 4x12 V30 SM57 Between 02.wav Engl Pro 4x12 V30 SM57 New 04.wav
Engl Pro 4x12 V30 SM57 Between 03.wav Engl Pro 4x12 V30 SM57 New 05.wav
Engl Pro 4x12 V30 SM57 Between 04.wav Engl Pro 4x12 V30 SM57 New 06.wav
Engl Pro 4x12 V30 SM57 Center 01.wav Engl Pro 4x12 V30 SM57 New 07.wav
Engl Pro 4x12 V30 SM57 Center 02.wav Engl Pro 4x12 V30 SM57 New 08.wav
Engl Pro 4x12 V30 SM57 Center 03.wav Engl Pro 4x12 V30 SM57 New 09.wav
Engl Pro 4x12 V30 SM57 Center 04.wav Engl Pro 4x12 V30 SM57 New 10.wav
Engl Pro 4x12 V30 SM57 Center 05.wav Engl Pro 4x12 V30 SM57 New 11.wav
Engl Pro 4x12 V30 SM57 New 01.wav Engl Pro 4x12 V30 SM57 New 12.wav
Engl Pro 4x12 V30 SM57 New 02.wav
pack/[SP] Framus 4x12 V30:
Framus 4x12 V30 SM57 01.wav
pack/[SP] Marshall 1960A 4x12 V30 + G12 (XP):
Marshall 1960A V30 SM57 - 01.wav
pack/[SP] Mesa Oversized 4x12 V30:
Mesa Oversized 4x12 V30 SM57 01.wav Mesa Oversized 4x12 V30 SM57 07.wav
Mesa Oversized 4x12 V30 SM57 02.wav Mesa Oversized 4x12 V30 SM57 08.wav
Mesa Oversized 4x12 V30 SM57 03.wav Mesa Oversized 4x12 V30 SM57 09.wav
Mesa Oversized 4x12 V30 SM57 04.wav Mesa Oversized 4x12 V30 SM57 10.wav
Mesa Oversized 4x12 V30 SM57 05.wav Mesa Oversized 4x12 V30 SM57 11.wav
Mesa Oversized 4x12 V30 SM57 06.wav
pack/[SP] Mesa Trad 4x12 V30:
Mesa Trad 4x12 V30 SM57 01.wav Mesa Trad 4x12 V30 SM57 05.wav
Mesa Trad 4x12 V30 SM57 02.wav Mesa Trad 4x12 V30 SM57 06.wav
Mesa Trad 4x12 V30 SM57 03.wav Mesa Trad 4x12 V30 SM57 07.wav
Mesa Trad 4x12 V30 SM57 04.wav Mesa Trad 4x12 V30 SM57 08.wav
strat@debian:~$ cp -r pack backup
strat@debian:~$ ls -R backup
backup:
[SP] Engl Pro 4x12 V30 [SP] Mesa Oversized 4x12 V30
[SP] Framus 4x12 V30 [SP] Mesa Trad 4x12 V30
[SP] Marshall 1960A 4x12 V30 + G12 (XP)
backup/[SP] Engl Pro 4x12 V30:
Engl Pro 4x12 V30 SM57 Between 01.wav Engl Pro 4x12 V30 SM57 New 03.wav
Engl Pro 4x12 V30 SM57 Between 02.wav Engl Pro 4x12 V30 SM57 New 04.wav
Engl Pro 4x12 V30 SM57 Between 03.wav Engl Pro 4x12 V30 SM57 New 05.wav
Engl Pro 4x12 V30 SM57 Between 04.wav Engl Pro 4x12 V30 SM57 New 06.wav
Engl Pro 4x12 V30 SM57 Center 01.wav Engl Pro 4x12 V30 SM57 New 07.wav
Engl Pro 4x12 V30 SM57 Center 02.wav Engl Pro 4x12 V30 SM57 New 08.wav
Engl Pro 4x12 V30 SM57 Center 03.wav Engl Pro 4x12 V30 SM57 New 09.wav
Engl Pro 4x12 V30 SM57 Center 04.wav Engl Pro 4x12 V30 SM57 New 10.wav
Engl Pro 4x12 V30 SM57 Center 05.wav Engl Pro 4x12 V30 SM57 New 11.wav
Engl Pro 4x12 V30 SM57 New 01.wav Engl Pro 4x12 V30 SM57 New 12.wav
Engl Pro 4x12 V30 SM57 New 02.wav
backup/[SP] Framus 4x12 V30:
Framus 4x12 V30 SM57 01.wav
backup/[SP] Marshall 1960A 4x12 V30 + G12 (XP):
Marshall 1960A V30 SM57 - 01.wav
backup/[SP] Mesa Oversized 4x12 V30:
Mesa Oversized 4x12 V30 SM57 01.wav Mesa Oversized 4x12 V30 SM57 07.wav
Mesa Oversized 4x12 V30 SM57 02.wav Mesa Oversized 4x12 V30 SM57 08.wav
Mesa Oversized 4x12 V30 SM57 03.wav Mesa Oversized 4x12 V30 SM57 09.wav
Mesa Oversized 4x12 V30 SM57 04.wav Mesa Oversized 4x12 V30 SM57 10.wav
Mesa Oversized 4x12 V30 SM57 05.wav Mesa Oversized 4x12 V30 SM57 11.wav
Mesa Oversized 4x12 V30 SM57 06.wav
backup/[SP] Mesa Trad 4x12 V30:
Mesa Trad 4x12 V30 SM57 01.wav Mesa Trad 4x12 V30 SM57 05.wav
Mesa Trad 4x12 V30 SM57 02.wav Mesa Trad 4x12 V30 SM57 06.wav
Mesa Trad 4x12 V30 SM57 03.wav Mesa Trad 4x12 V30 SM57 07.wav
Mesa Trad 4x12 V30 SM57 04.wav Mesa Trad 4x12 V30 SM57 08.wav
strat@debian:~$ rename backup/*/*.wav *.txt
Bareword found where operator expected at (eval 1) line 1, near "] Engl"
(Missing operator before Engl?)
Bareword found where operator expected at (eval 1) line 1, near "12 V30"
(Missing operator before V30?)
Bareword found where operator expected at (eval 1) line 1, near "12 V30"
(Missing operator before V30?)
Number found where operator expected at (eval 1) line 1, near "Between 01"
(Do you need to predeclare Between?)
syntax error at (eval 1) line 1, near "] Engl Pro "
strat@debian:~$
Im stuck at renaming part..Im not even sure that is the correct command..and Im assuming the errors I am getting are from the files having spaces in there names..First question is can I easily get rid of the spaces and replace them with a "_"..and then if that rename command is right.This is just a test trying to figure out the right commands..Im not trying to change a.wav to a text file..Its just the extension I used..could have been .mp3,.avi...etc..And If i can get the rename command i should be able to do this with just one command.
In the past, I would download my updates on high speed internet at a different location because one of my residences has dial-up. I would use firefox in Debian, but downloaded to a FAT32 USB stick, for some reason it would download the file with correct name but would add a second extension, example:
package.rpm became package.rpm.rpm
This is how I would rename the files to remove the second extension, this command would have to be run from the directory containing the double extension files:
for i in *.rpm.rpm; do mv "$i" "`basename $i .rpm.rpm`.rpm"; done
Try adding this (below) to your command, make sure to have a recursive option in the right place to do it recursively.
for i in *.ewav; do mv "$i" "`basename $i .ewav`.wav"; done
but that way wont do multiple directories?I would have to cd into each directory where files are.Which isnt bad if it 1-2-3 directories but like 20 or so..I found this way of doing it but cant seem to get the context right..Ill have to work on it later..His uses "f" instead of "i" http://thetechforums.net/howToLinux/?p=19
Folder Im going to convert has like 30-40 folders or so and some folders contain 1-2 .ewav files and some contain 10 or so..so cding into each directory and doing this is quite tedious..I might just have to boot into windows to do this..I had done this before last year or so and used a free utility to rename .ewav to .wav .. it was just a matter selecting folder and right click..and it handled all the files in subfolders.
ok..just incase anyone else needs to change alot of files extensions in multiple directories..I downloaded a little windows app that works perfect in wine..just drag and drop folder onto it and it works perfect..its called ezXTN.. http://www.sph.sc.edu/comd/rorden/ezxtn.html
yeah..but that sure is alot to type.and to remember.its kinda hard to beat drag&drop..like i said..that little windows app works great in wine..tried another one called extension changer..works well under wine to..Would think that someone would have developed at little app to do this in linux..??
I searched through synaptic and found a few rename apps..PyRenamer seems to be what i was looking for.It will do everything I need,I can set it to do a directory and all its subfolders...it will remove spaces and replace with "_"..and change extension all with 1 click..
yeah..but that sure is alot to type.and to remember.its kinda hard to beat drag&drop..like i said..that little windows app works great in wine..tried another one called extension changer..works well under wine to..Would think that someone would have developed at little app to do this in linux..??
All you have to do is make a oneliner script from it, and copy it to your ~/bin/ directory. Then run the script when you need to.
No need to use a windows app. You never know where it's been!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.