You could give the files names like 1,2,3,... and keep an index to associate the numbers to names
2011/11/22 Skip Cave <[email protected]> > I have been looking for a function that will parse through my big directory > tree and append the containing directory name to the file names of specific > files in that directory. I haven't had much luck, so far. > > I found Henery Rich's phrasesfiles.ijs scripts. However, I haven't figured > out how to get those functions to rename all the files in a folder at once. > Those functions will access specific files with wildcards, but not all the > files. > > Also, the current directory names are really long (several hundred > characters) so the resulting file names would be pretty cumbersome. I would > prefer to use a unique integer to append to all the file names in each > directory, as that makes the file names manageable, as well as easier to > handle and select. > > Skip > > On Tue, Nov 22, 2011 at 6:16 AM, Raul Miller <[email protected]> > wrote: > > > Why not keep the directory names as prefixes to the file name? (Remove > the > > directory separator for the rename)? > > > > -- > > Raul > > > > On Tue, Nov 22, 2011 at 3:05 AM, Skip Cave <[email protected]> > > wrote: > > > > > The data structure I am working on has a directory structure that is > > > several levels deep. At the deepest level, there are over 10,000 > > > directories. Only the lowest-level directories contain files. > > > > > > Each of the lowest-level directories contains one file labeled ' > log.gz', > > > and several sequentially-labeled files named > > > 'ep_call00000_utt00001.wav.gz', ep_call00000_utt00002.wav.gz', etc. > There > > > are some other files in this lowest-level directory that we can ignore. > > > > > > I want to extract all the log.gz files and all the wav.gz files in all > > > these thousands of lowest-level directories and put them all in a > single > > > directory. However, all the log files have the same name, and the > wav.gz > > > files will also have conflicting names. So I need to rename the files > > > before putting them all in one directory. > > > > > > In addition, I need to keep the association between the log file in > each > > > directory, and the various wav.gz files that were also in that same > > > directory. > > > To do this, I would like to rename each log.gz file to a number which > is > > an > > > integer between 1 & 100,000, labeled sequentially. I would also like > that > > > same integer to replace the 'ep_call0000' portion of the wav.gz file > name > > > of each of the wav.gz files which are in the same directory as the > log.gz > > > file, while maintaining the sequential numbering of the last part of > the > > > wav.gz name. Each lowest-level directory would have its files renamed > > with > > > the next higher integer. > > > > > > The files in the first lowest-level directory are named 'log.gz', > > > 'ep_call00000_utt00001.wav.gz',and ep_call00000_utt00002.wav.gz'. We > > > would rename these files to: 100000log.gz, 1000000_utt00001.wav.gz', > and > > > 100000_utt00002.wav.gz', and then put the renamed files in the new > common > > > directory. > > > > > > The files in the second lowest-level directory are named 'log.gz', > > > 'ep_call00000_utt00001.wav.gz', 'ep_call00000_utt00002.wav.gz', and > > > 'ep_call00000_utt00003.wav.gz'. We would rename these files to: > > > 100001log.gz, 1000001_utt00001.wav.gz', 100001_utt00002.wav.gz'', and > > > '100001_utt00003.wav.gz', then put the renamed files in the new common > > > directory. > > > > > > We would continue the rename/copy process until all of the log & wav > > files > > > had been renamed and copied to the new directory. > > > > > > Is there a simple way to do this in J, or should I be looking at a > > > command-line batch file for this kind of job? > > > > > > Skip > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > > -- > Skip Cave > Cave Consulting LLC > Phone: 214-460-4861 > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Björn Helgason, Verkfræðingur Fornustekkum II 781 Hornafirði, t-póst: [email protected] gsm: +3546985532 twitter: @flugfiskur http://groups.google.com/group/J-Programming Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans góður kennari getur stigið á tær án þess að glansinn fari af skónum /|_ .-----------------------------------. ,' .\ / | Með léttri lund verður | ,--' _,' | Dagurinn í dag | / / | Enn betri en gærdagurinn | ( -. | `-----------------------------------' | ) | (\_ _/) (`-. '--.) (='.'=) ♖♘♗♕♔♙ `. )----' (")_(") ☃☠ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
