Help cmd not working right what am i missing

September 7, 2010 at 18:09:00
Specs: Windows XP

Im grabing all item one at a time form folder 1 and then move file into folder 2 in a folder [next number from store in file]--filename\idem

..........................

for /f %%a in ('dir /s/b/o:n d:\Make_porable\1_download\*.*') do (

set /p jk=<d:\make_porable\count.txt
echo 1 %jk%
set /a jk=%jk%+1
echo 2 %jk%
md "D:\make_porable\2_Folder\%jk%--%%~na"
xcopy "%%a" "D:\make_porable\2_Folder\%jk%--%%~na"
echo 1 %jk%
set /a jk=%jk%+1
echo 1 %jk%
echo %jk%>d:\make_porable\count.txt

)

pause


See More: Help cmd not working right what am i missing

Report •


#1
September 7, 2010 at 18:26:40
If %jk% equals 1 or 2 it will not work correctly. You will need to escape the angled brackets with a caret (^).

echo %jk%^>d:\make_porable\count.txt

Can I put a question here?


Report •

#2
September 7, 2010 at 18:45:21
that just put the %jk% in to the "count file" not on the from on the folder

but when I do it in two file for the cmd

------1-to-2.cmd----


for /f %%a in ('dir /s/b/o:n d:\Make_porable\1_download\*.*') do (

call ej.cmd %%a

)

::pause
------

------ej.cmd-----------
set /p jk=<d:\make_porable\count.txt
md "D:\make_porable\2_Folder\%jk%--%~n1"
xcopy "%1" D:\make_porable\2_Folder\%jk%--%~n1
set /a jk=%jk%+1
echo %jk%>d:\make_porable\count.txt

-------

I start the count.txt at 100001

--


Report •

#3
September 7, 2010 at 22:06:36
Read up on delayed expansion, it will allow variables marked with !'s to update in loops, if statements and other code block structures.

echo %jk%>d:\make_porable\count.txt

Try this:

>d:\make_porable\count.txt echo %jk%


Report •

Related Solutions

#4
September 7, 2010 at 22:12:56
untested
SetLocal EnableDelayedExpansion

set /p jk=<d:\make_porable\count.txt

for /f %%a in ('dir /a-d/s/b/o:n d:\Make_porable\1_download\*.*') do (
    set /a jk+=1
    md "D:\make_porable\2_Folder\!jk!--%%~na"
    copy "%%a" "D:\make_porable\2_Folder\!jk!--%%~na"
)

> d:\make_porable\count.txt echo !jk!

pause


Report •


Ask Question