I was going to put this in GQ but thought this would be better.
I have a folder with a collection of files in it. Over 4000 files to be exact.
The folder resides on a Suse 10.2 Linux box but is accessable over the network to my Windows XP Systems.
All of my computers have read and write access to the folder. Further the folder is mapped to the XP systems as k:
The files all adhere to the same naming standard of
“AABBBB-CC_DDDDDDDDDD_EEEEE_-_FFFFFFFFFFF”
where _ is the space character
AA is two letters
BBBB is four numbers
DDDD
EEEEE
and FFFFFF
can be any length.
I assume if I do this on linux there would be a way to send the output of ls to a file, parse the first 5 characters and see if a folder exists with that name. If it does then issue a mv command using the first 5 characters and the wildcard. If the folder does not exist then it would make it then do the moving and then go through the rest of the ls command.
I don’t know about linux - from windows you can do it with a .vbs scripting file:
set fso = createObject("Scripting.FileSystemObject"
set rootFold = fso.getFolder ("k:\")
for each efile in rootFold.files
nprefix = left(efile.name, 5)
if not fso.folderExists ("k:\" & nprefix) then
fso.createFolder "k:\" & nprefix
end if
efile.move "k:\" & nprefix & "\"
next
set rootfold = nothing
set fso = nothing
(Code has not been tested, might need to specify the entire new pathname in efile.move.)
Hope that this helps out a bit. Moving the files one at a time is much easier than using wildcard moving, because it doesn’t mess up the for each in files loop so badly.
chrisk, thanks I did notice the missing ) I did use the full path in " marks because there were spaces but it failed due to a permissions problem on the share side that I have to fix