looping help


#1

I am using exports to create batch files

the following is one I wrote

$filename("txt")
echo off
echo %_folderpath%
$loop(%_folderpath%)
if not EXIST "c:\music\\%artist%\" md "c:\music\\%artist%\"
if EXIST "%_folderpath%" move "%_folderpath%*.*" "c:\music\\%artist%\" 
if EXIST "%_folderpath%" rd "%_folderpath%"
$loopend()
pause

it is supposed create loop once per directory.
the batch file when should give me one set of three commands per DIRECTORY

create a direcotry if it doesn't exists
move the files ( including notes and images)
remove the old dorecotry

output looks like this

if not EXIST "c:\music\Asia" md "c:\music\Asia"
if EXIST "C:\music\_ripped\Asia\" move "C:\music\_ripped\Asia\*.*" 
if EXIST "C:\music\_ripped\Asia\" rd "C:\music\_ripped\Asia\"

if not EXIST "c:\Asia\" md "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" move "C:\music\_ripped\Asia\*.*" "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" rd "C:\music\_ripped\Asia\rd "C:\music\_ripped\Asia\

if not EXIST "c:\Asia\" md "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" move "C:\music\_ripped\Asia\*.*" "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" rd "C:\music\_ripped\Asia\rd "C:\music\_ripped\Asia\

if not EXIST "c:\Asia\" md "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" move "C:\music\_ripped\Asia\*.*" "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" rd "C:\music\_ripped\Asia\rd "C:\music\_ripped\Asia\

if not EXIST "c:\Asia\" md "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" move "C:\music\_ripped\Asia\*.*" "c:\Asia\"
if EXIST "C:\music\_ripped\Asia\" rd "C:\music\_ripped\Asia\rd "C:\music\_ripped\Asia\

if not EXIST "c:\Bad Company\" md "c:\Bad Company\"
if EXIST "C:\music\_ripped\Bad Company\" move "C:\music\_ripped\Bad Company\*.*" "c:\Bad Company\"
if EXIST "C:\music\_ripped\Bad Company\" rd "C:\music\_ripped\Bad Company\rd "C:\music\_ripped\Bad Company\

if not EXIST "c:\Bad Company\" md "c:\Bad Company\"
if EXIST "C:\music\_ripped\Bad Company\" move "C:\music\_ripped\Bad Company\*.*" "c:\Bad Company\"
if EXIST  "C:\music\_ripped\Bad Company\" rd "C:\music\_ripped\Bad Company\rd "C:\music\_ripped\Bad Company\
pause

or one set of commands for each file

whats wrong

it works fine becaue it doesnt ry to execut the extra commands ebcasue they fail


#2

What about $loop(%_folderpath%,1) ?


#3

that works
but why? what is the significance of the 1


#4

If you want to limit the loop to a certain number of entries per loop partition, simply use $loop(%fieldname%,num). This is useful to eliminate duplicate records (num=1).


#5

thx for the explanation