jumper, on 10 October 2012 - 03:06 PM, said:
Since there will be
some copying or linking, perhaps rather than doing any move/copy/deleting, consider
always creating a link:
- The original files would never be touched. You would always be able to start over from scratch--even after you thought you had a "final" solution.
- The links could be created in a compressed folder to prevent them from consuming as much space as the originals

- They could be renamed independently from the original or each other ( "Apple and Oranges..." -> "Oranges and Apples...") in the respective target folders.
I really like that concept, and in other situations that would be perfect (already thinking of some possibilities). The problem with THIS one is that this is part of the cleanup and organizing before allowing a database to run an automated scrub of everything internal to each file. I've already had to scratch everything and start over. Getting this external automation working takes a huge load off my manual workload... especially when considering the continuous flow of more files being added.
BTW, I've run this in a sub-group of the actual files, and I've found a few additional scenarios.
Add these files to see:
Pineapples - The first cut.txt
The Big Apple (New York).txt
Since Pineapple includes "apple", it's moved incorrectly. Putting a space in front of the word check fixes it... but messes with everything else.
The Big Apple... causes issues if the word checked isn't at the beginning.
Here's the fixed code that allows these as well (also added remarks to beautify):
@ECHO OFF
REM ****************** Loop subroutine for each item in List.txt
FOR /F "delims=;" %%i in (List.txt) do (
call :testsub "%%i"
)
GOTO :End
REM ****************** Subroutine(s)
REM ****************** Search the filenames for an instance of the list item anywhere (with a space in front of it)
:testsub
FOR /F "delims=;" %%j in ('DIR /B *" "%1*.*') do (
IF NOT EXIST .\%1 md %1
MOVE "%%j" .\%1\
)
REM ****************** Check the beginning of the filename for the list item
FOR /F "delims=;" %%j in ('DIR /B %1*.*') do (
IF NOT EXIST .\%1 md %1
MOVE "%%j" .\%1\
)
GOTO :EOF
:End
Also of note... List.txt needs to be arranged in a way that puts the more important folders to be hit first. For instance, if I include "grape" in the list as a catch all for any grapes not accounted for (red grape, seedless, etc), it should be put under the more specific grape types. This is, of course, not an issue if the files are not moved or deleted as in my code above.
Thanks for the help everyone.
I think I'll end up using this version. Maybe at another time, I'll create a script to search the folders and copy any multi-'fruit' files needed... then append it to this script.