Hi
I have a large directory structure that I wish to copy, and I only want to copy those directories which contain a specific number of files inside them
Can I do this, and if so how? Can't figure out the copy filter, but may be dense
Mike
Hi
I have a large directory structure that I wish to copy, and I only want to copy those directories which contain a specific number of files inside them
Can I do this, and if so how? Can't figure out the copy filter, but may be dense
Mike
I can think of one way of doing this but it's not a brilliant solution. Can you elaborate on what you're trying to do? Maybe there's a better way than what I'm thinking of.
e.g. Are you only trying to move files of a certain type?
The directory stucture I have is from a set of medical images, and all of the files in the structure are of the same type
There are 5000 subjects, each subject has 16 subdirectories, and in these subdirectories there are varying number of files. The number of files in each of the subdirectories provide a key to the imaging sequence used - so some directories have 1 image, some 35, some 160.
I want to copy only the directories which contain 35 images to another directory, to dramatically slim down the size of the directory (as I don't need the others. I could do this by hand, but it's tiresome
MIke
I would choose View -> Flat View -> Mixed and then add the General -> File Count column and sort by it.
Once Opus finishes reading the directory information you can now scroll down the list of directories and easily see the ones which have the desired number of files in them. They'll be grouped together so you can easily select them and copy them out.
You can probably speed things up a bit by first hiding all files, using a filter box for example, so that when you switch to Flat View you're only seeing directories.
The File Count column only counts files directly below the folder. If you want to include files in sub-folders then there's a separate Total File Count column. There are also similar columns which display the number of direct sub-folders and total sub-folders.
[quote="mikebo"]The directory stucture I have is from a set of medical images, and all of the files in the structure are of the same type
There are 5000 subjects, each subject has 16 subdirectories, and in these subdirectories there are varying number of files. The number of files in each of the subdirectories provide a key to the imaging sequence used - so some directories have 1 image, some 35, some 160.
I want to copy only the directories which contain 35 images to another directory, to dramatically slim down the size of the directory (as I don't need the others. I could do this by hand, but it's tiresome
MIke[/quote]
You might want to do it with WSH scripting if you are comfortable with such... The following (old style .vbs) file will take 2 inputs, the starting directory name and the number of files to use as a criteria. It will then search through the subdirectories of that starting point and list the names of the files in directories that have more than the second input.
For instance, if I run it from the command line as so:
cscript test.vbs c:\ 24
It will list the files in C:\windows (I am running it on Vista) and a test directory I made but it will only show how many files are in all other folders.
You can change the echo statements to folder.copy or file.copy statements. Be aware that folder.copy is recursive.
You can make a button that does someting like
path:\test.vbs {sourcepath$} 34
To go through the the directory selected in the source lister. It will show only folders with more than 34 files. If you do this via Opus, you will get a messagebox for each file name, probably NOT what you want to do. Develop and test from the command line, using cscript and then move to D.O.
Note that I have not put much, if any, error checking to keep it brief.
Sorry if this is a waste of bandwidth.
set obj=CreateObject("Scripting.FileSystemObject")
set arguments=Wscript.arguments
if arguments.count>1 then
set folder=obj.GetFolder(arguments(0))
set folders=folder.subfolders
for each subfolder in folders
set files=subfolder.Files
Wscript.Echo cstr(files.Count) + " files in folder "+subfolder.Path
if files.count > cint(arguments(1)) then
for each thefile in files
Wscript.Echo thefile.name
next
else
Wscript.Echo "not more than "+ arguments(1)+" files"
end if
next
end if
Hi
Thanks for the suggestion - I did eventually solve the problem using an old copy of Visual Basic, and something very close to that suggested, though using the FindFirstFile methods
Thanks very much for the suggestions though
Best wishes
mike