Help - Python syntax - repeats script through subordinate folders
I'm NOT a programmer…. but I have a little Python script that converts files, that are in a folder, from one format to another. Script = fxp2aupreset.py I can successfully run it from the command line: 1st, I placed the folder that I named 'ddd' on the desktop so that it's easy to get to. 2. Terminal : cd ~/Desktop/ddd 3. Then I run the script from terminal : python ./fxp2aupreset.py ./ aumu Alb3 LinP vstdata It executes fine and does it's job. BUT… I have per 7600 files that are segregated into 86 folders. I want to keep this folder structure. So, What I need the script to do is to start at the parent folder (ddd) and then go through each subordinate (child) folder and perform its task on all files. I found this syntax on the web that is somehow supposed to do what I need: for /r %a in (*.fxp) do example.py "%a" BUT … I have no idea how to combine the syntax. Could someone put this together for me please. Something that I could just copy and paste into Terminal. I would be most grateful. Thank you very much! -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Python syntax - repeats script through subordinate folders
On Saturday, September 7, 2013 9:56:25 PM UTC-4, Chris Angelico wrote: > Your initial command and path suggest you're on a Unix-like system > > (these days that most likely means either Linux or Mac OS), but the > > FOR command at the end is a Windows command, so that's not going to > > work. However, Unix does have a find command, so that should work Hi Chris. Thank you so much for your rely. Yes…. I am doing this on a Mac OS > > Do you need to run your script once for each file, or once for each > > directory? Based on your use of "for /r", I'm thinking once per > > directory. I wish to run the script just once on the parent folder…. and have it run through all the 86 subordinate folders that reside in that parent folder. > $ find -type d -execdir bash -c 'cd {}; python ./fxp2aupreset.py ./ > > aumu Alb3 LinP vstdata' \; > > > I'm sure there's a tidier way to do it, but this should work! OK I will try that as soon as I can and post the results. FWIW: I'm not convened with 'tidy' … as I will only being coin this once. So very kind of you to help. HT to you sir. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Python syntax - repeats script through subordinate folders
Failed: Here is the command with the results: CiMac:ddd camforx$ $ find -type d -execdir bash -c 'cd {}; python ./fxp2aupreset.py ./ aumu Alb3 LinP vstdata' \; -bash: $: command not found -- With CiMac = HD ddd = folder on the desktop of user camforx -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Python syntax - repeats script through subordinate folders
I 'think' I did as you instructed …. but that too failed. :( CiMac:ddd camforx$ find -type d -execdir bash -c 'cd {}; python ./fxp2aupreset.py ./ aumu Alb3 LinP vstdata' \; find: illegal option -- t usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression] find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression] -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Python syntax - repeats script through subordinate folders
Thanks guys … that too failed. It's late here and I'm bushed. I'll get back to this tomorrow morning. Much appreciated. It's probably important that I point out that I put the file ' fxp2aupreset.py ' in the root directory (ddd) . Just to keep things all together. Again …. I have NO idea how to do any of this. Also …the root folder only contains the .py file and subfolders. The subfolders contain 100's of the files that I wish to convert. If you want to take a look at the last results …. In my DropBox here >> https://dl.dropboxusercontent.com/u/65969526/Results.rtf Good night all, and thank you again. -- https://mail.python.org/mailman/listinfo/python-list