Computer Hope
Microsoft => Microsoft DOS => Topic started by: strokeman on January 27, 2013, 10:01:41 PM
-
??? i want to write a batch file that creates a dir.tmp and processes that to make a directory of the same name LESS the .TBN extension, so it needs to rtrim te string and parse back to %G. Otherwise it will try and create a dir with the same name as the file and crash! you can see the commented out attempt to concatenate.
@cls
SET MyVar=.TBN
@ECHO OFF
COLOR 70
ECHO ------------------------------
ECHO XBMC TBN TO DIR Creator V0.99
ECHO ------------------------------
ECHO be sure you have run a seperate
echo export first, you will need to
echo run a database rebuild next....
pause
COLOR
@echo off
DIR /B *.TBN >DIR.TMP
FOR /F %%G IN (DIR.TMP) DO MD %%G
:Call :TRIM %%MyVar%%
:Echo MyVar=[%%MyVar%%]
:Set MyVar =
:echo %%G
:GoTo :EOF
:TRIM
:Set MyVar=%%*
:GoTo :EOF
MD %%G
:move /Y %%G.* ..%%G
-
Wait! what is wrong with a directory and file having the same name?
It is not clear what you want to do.
-
I hope I understood what you were after:
@echo off
for %%a in (*.tbn) do md "%%~na"
If you want to move the set of files into the corresponding new folder then this should work:
@echo off
for %%a in (*.tbn) do md "%%~na" & move "%%a" "%%~na"
-
Wait! what is wrong with a directory and file having the same name?
It's not possibubble, when they are in the same folder, if the folder has the extension too.
-
If you want to move the set of files into the corresponding new folder then this should work:
@echo off
for %%a in (*.tbn) do md "%%~na" & move "%%a" "%%~na"
assuming %~na is the truncated result, i.e tiger from tiger.tbn, what do i use to copy tiger.* wildcards ? what is %a the tiger.tbn filename?
-
Possibubble ? ?
-
Possibubble ? ?
Yep. It's impossibubble. And the people at the hostipital told me so.
If the file is named file.txt then you can't also have a folder named file.txt in the same location.
-
assuming %~na is the truncated result, i.e tiger from tiger.tbn, what do i use to copy tiger.* wildcards ? what is %a the tiger.tbn filename?
if you have a file called tiger.tbn and also want to move tiger.txt and tiger.pdf then you can use this:
@echo off
for %%a in (*.tbn) do md "%%~na" & move "%%~na.*" "%%~na"
-
that did the trick, but more to the point i understand it now
i have been trying to echo a blank line, normally id use ALT+ 032 I Think for a blank char, but this keyboard is made for stroke tetraplegics of which im one
lastly i wish to create a blank file as a marker in an EXIST loop, but without user intervention, ie a >nul, what can i do?, edlin reqs ^Z, for example... :(
-
The two ways to test for a folder and a file. Note the trailing backslash when testing for a folder.
if exist "c:\folder\" type nul >"c:\folder\flagfile.bin"
if exist "c:\autoexec.bat" type nul >"c:\flagfile.bin"
-
A third way... use the ~a variable modifier with FOR like this
for %%I in ("name") do set AttributeString=%%~aI
"name" is a file or folder name (which must exist!) e.g. "d:\temp\test.txt" or "C:\" or "D:" (no trailing slash needed for folders)
AttributeString is an arbitrary name I chose to hold the result which is a string 9 characters long which has either a lower case letter or a dash in each character position like this: drahscotl. If the attribute is set, the letter is present, if the attribute is unset, there is a dash.
Not all the attributes may be present on all file systems, but they are all possible on NTFS.
for a folder with no attributes set you would have d--------
for a folder which is hidden, system and a junction point or link*, e.g. "My Documents" you see d--hs---l
for a file ready for archiving with no special attributes you would see --a------
the letters mean:
d a directory
r read only
a ready for archiving
h hidden
s system
c compressed
o offline
t temporary
l link/junction point*
Thus:
if "%AttributeString:~0,1%"=="d" then name is a directory
if "%AttributeString:~0,1%"=="-" then name is NOT a directory
* http://comptb.cects.com/2268-overview-to-understanding-hard-links-junction-points-and-symbolic-links-in-windows
-
Note: the c (compressed) attribute refers to NTFS compression, not any other type such as Zip.
-
a fourth way...
dir /ad /b "name">nul 2>&1 && (set isfolder=yes) || (set isfolder=no)
-
Yet another way. :D
dir "d:\folder"|find ">">nul && echo it's a directory
dir "d:\file.txt"|find ">">nul || echo it's a file
-
why is the condition never met?
@cls
@ECHO Off
ECHO +-----------------------------+
ECHO :XBMC NFO TO DIR Creator V1.0:
ECHO +-----------------------------+
ECHO.
IF NOT EXIST NFO2DIR.TXT (
ECHO Don't be a bigshot, R.T.F.M Before you run, Press ^^C if you want to abort. .
ping localhost -n 4 >nul
) else (
START notepad /P NFO2DIR.TXT
TYPE NUL>"nfo2dir.prn"
goto bypass
)
if exist nfo2dir.prn (
echo Printed already. . .
ping localhost -n 4 >nul
)
if exist nfo2dir.txt (
START /MAX notepad nfo2dir.txt
)
:bypass
IF NOT EXIST *.NFO (
ECHO It appears you haven't run vid. export yet!
ping localhost -n 4 >nul
exit
)
if not exist "nfo2dir.done" (
type nul >"nfo2dir.done"
) else (
ECHO You have processed already
ping localhost -n 4 >nul
exit
)
echo Please wait. . DON'T INTERUPT!!
ping localhost -n 4 >nul
for %%a in (*.NFO) do md "%%~na" & move /y "%%~na.*" "%%~na" & move /y "%%~na-fanart.*" "%%~na" & move /y "%
%~na-poster.*" "%%~na" & move /y "%%~na-thumb.*" "%%~na"
if EXIST extrathumbs (
rd /s /q extrathumbs
)
if EXIST extrafanart (
rd /s /q extrafanart
echo extrafanart and extrathumbs dir. deleted
) ELSE (
echo extrafanart or extrathumbs dir. not found. . .
)
dir /s ::do directory list including subdirs.
@cls
echo Operation Completed Successfully.
-
It will only run if these two conditions are true:
IF NOT EXIST NFO2DIR.TXT
if exist nfo2dir.prn
because if NFO2DIR.TXT exists it will goto :bypass
-
can anyone see why <moviename>-CD1 would not be processed pls?
@cls
@ECHO Off
ECHO +-----------------------------+
ECHO :XBMC NFO TO DIR Creator V1.1:
ECHO +-----------------------------+
ECHO.
IF not EXIST NFO2DIR.TXT (
ECHO Don't be a bigshot, R.T.F.M Before you run, Press ^^C if you want to abort. .
ping localhost -n 4 >nul
) else (
START /max notepad NFO2DIR.TXT
)
IF NOT EXIST *.NFO (
ECHO It appears you haven't run vid. export yet!
ping localhost -n 4 >nul
exit
)
if not exist "nfo2dir.done" (
type nul >"nfo2dir.done"
attrib +h +r nfo2dir.done >nul
) else (
ECHO You have processed already
ping localhost -n 4 >nul
exit
)
echo Please wait. . DON'T INTERUPT!!
ping localhost -n 4 >nul
for %%a in (*.NFO) do md "%%~na" & move /y "%%~na.*" "%%~na" & move /y "%%~na-fanart.*" "%%~na" & move /y "%%~na-poster.*" "%%~na" & move /y "%%~na-thumb.*" "%%~na"
if EXIST extrathumbs (
rd /s /q extrathumbs
)
if EXIST extrafanart (
rd /s /q extrafanart
echo extrafanart and extrathumbs dir. deleted
) ELSE (
echo extrafanart or extrathumbs dir. not found. . .
)
dir /s ::do directory list including subdirs.
@cls
echo Operation Completed Successfully.
-
There isn't enough information - try putting echo and pause commands to see which loop is causing it to be skipped.
-
dir /s ::do directory list including subdirs.
Probably not (directly) related to the problem, but this will not do what you appear to hope it will. By the way, this is how you spell interrupt. And do we need to see "R.T.F.M"?
-
yes, bit abrupt, but so are the irreversible disk changes that are made, so makes sure user has read and understands that. well spotted, i do know how to spell, but being disabled and wheelchair bound after a stroke, left me with one partially working limb, and the non dominant one at that, so i stab away and many typos creep in.
-
There isn't enough information - try putting echo and pause commands to see which loop is causing it to be skipped.
have broken it down, and created dummy files. it does work. there was no corresponding nfo file, twas all! 8)
-
yes, bit abrupt
The 'F' in RTFM stands for a profane word. This is a site accessed by people of all ages.
-
'Read the fine manual'? I have no issues with that... ;)
It's good to see you using your skills strokeman, and making the best of a hard situation. My bro had a stroke too.
-
The 'F' in RTFM stands for a profane word. This is a site accessed by people of all ages.
FREE is profane?, chillax, those that know what it stands for, might be bemused, those that don't, i.e. kids, still don't. one thing my accident taught me is 'to live every day like its your last, you never know it just might be" smell the roses fella..
-
so i want 2 parse %1, the commandline var that would be -cd1 in this case, how to trim in this case 4 chars?
for %%a in (*%%1.*) do md "%%~na-count[%%1)" & move "%%~na.*" "%%~na" of course know this wont work, just thinking out loud!
-
so i want 2 parse %1, the commandline var that would be -cd1 in this case, how to trim in this case 4 chars?
This will give you the last 4 characters:
set "var=%~1"
set "num=%var:~-4%"
echo "%num%"
pause
This will give you the name, without the last four characters.
set "var=%~1"
set "name=%var:~0,-4%"
echo "%name%"
pause
-
so as there doesn't seem to be a string type funct that determines the length of %1 in chars, ill parse 2 params like -cd1 4, .disk1 6 etc.
here i get lost, for the dummyfile test-cd1.avi, id expect %name% to be test. its not. how to implement in the for/do loop?
this is what i have so far
@ECHO OFF
@CLS
set "var=%~1"
set "num=%var:~-%2%"
echo num="%num%"
pause
set "name=%var:~0,-%2%"
echo name="%name%"
pause
for %%a in (*%1.*) do md "%%~na" & move "%%~na.*" "%%~na"
for the cd1 4 test, it returns
%num%=%var:~-4 when id expect -4
%name%=%var:~0,-4 when id expect test
what am i not seeing foxidrive man?
-
See if this gives you what you want. Your issue was having %2 there.
JFTR It helps a lot to describe what you want to do and supply some filenames. There are other methods to parse filenames and the best way depends on what you need and what the makeup of the filenames are.
@ECHO OFF
set "var=%~n1"
echo filename is "%~n1"
set "num=%var:~-2%"
echo num="%num%"
set "name=%var:~0,-2%"
echo name="%name%"
pause
-
fair comment, ill try to be more specific,
lets assume there r 2 files, named test-cd1.avi and test-cd2.avi
" " " the batch file is test.bat
so we enter test -cd1 4 at commandline
we want the for/do loop to md called test, thus trim off the four last digits
& into that dir, move test-cd1.avi and test-cd2.avi
the %1 an %2 vars could be anything, i.e .disk1 6, -dvd1 5 etc
i was expecting '-4' for %num%, and %name% = 'test'
hth
-
if they are all formatted 'test-something', you can use
for /f "tokens=1,2 delims=-" %%A in ('dir /b') do (
if not "%%A"=="%~n0" (
if not exist %%A md %%A
move /y "%%A-%%B" "%%A\%%A-%%B"
)
)
but you may have to change the delim if they don't have '-'.
-
fair comment, ill try to be more specific,
lets assume there r 2 files, named test-cd1.avi and test-cd2.avi
" " " the batch file is test.bat
so we enter test -cd1 4 at commandline
The batch file is called test.bat
So you entered test -cd1 4
But you are not passing the filename - how does the batch file know which filename(s) to operate on?
-
it changes each iteration, its from the for/do loop which processes the wildcard based on %1, in this case *-cd1.*. i guess im wanting -cd1 removed from the current file. the %2 giving the number of chars to remove, tho would much rather have a function that determines this from %1.
so its what to do with
for %%a in (*%1.*) do md "%%~na" & move "%%~na.*" "%%~na"
clear as mud?
-
If you are trying to sort groups of files but there are numerous suffixes on them, then you can do it in batches semi-manually.
This should take avi files ending in -cd1, -cd2, -cd3, -cd4 (or -cd with any next character) and move them into respective folders, named from the filename without the ending 4 characters.
@echo off
set end=-4
for %%a in (*-cd?.avi) do call :next "%%a"
echo done
pause
goto :EOF
:next
set "var=%~n1"
call set "var=%%var:~0,%end%%%"
md "%var%" 2>nul
echo moving %1 to "%var%"
move "%~1" "%var%" >nul
repeat with different filespecs and the appropriate number for the length of the suffix.
Filenames with % and ^ in them could cause issues.
-
u make it look easy!, im struggling to understand it
works fine putting in each variation on commandline
now if only i could get it todo 3 increments, without changing %1 and running it again.
how do we add 1 to %%a?, is it even poss.?, what about doing stuff to %2?
@echo off
set end=-%2
for %%a in (*%1.*) do call :next "%%a"
goto :EOF
:next
set "var=%~n1"<---w t f is n1?
call set "var=%%var:~0,%end%%%"
md "%var%" 2>nul <--- w t f does the 2 do?
move "%~1" "%var%" >nul
-
now if only i could get it todo 3 increments, without changing %1 and running it again.
We are guessing what you are doing. It's hard to give advice without knowing the task.
set "var=%~n1"<---w t f is n1?
Read the help for for /? and you'll find it at the end.
md "%var%" 2>nul <--- w t f does the 2 do?
In this case it eliminates a message in STDERR about the folder already existing. The error message goes to NUL when the folder already exists.
-
md "%var%" 2>nul <--- w t f does the 2 do?
In this case it eliminates a message in STDERR about the folder already existing. The error message goes to NUL when the folder already exists.
My way of getting around that is to do an IF EXIST test e.g. if not exist logfolder md logfolder
-
My way of getting around that is to do an IF EXIST test e.g. if not exist logfolder md logfolder
That's the traditional and effective and sensible way - I'm lazy in some respects and go for the 2>nul these days.
I do the same with del filename.txt 2>nul
-
can live with your solution, but surely there's a function about to count the chars in %1 instead of %2?
eg commandlines
-cd1 4
.disk1 6
-
@echo off
set a=%1
setlocal EnableDelayedExpansion
set b=1
:loop.countChar.2
call set c=%%a:~!b!,1%%
if "%c%"=="" goto end
set /a b+=1
goto loop.countChar.2
:end
echo %2 %b%
pause
will count the number of characters in argument 1 (%1). It's kinda long, but works relatively well.
C:\Users\Lemonilla\Documents\bat>call countCharInArg2.bat thisIs16CharLong 1
thisIs16CharLong 16
Press any key to continue . . .
C:\Users\Lemonilla\Documents\bat>
EDIT: misread your post, fixed code to count from arg 1 and not arg 2.
-
I know this doesn't work, how can i pass no .nfo file, AND no commandline given?
IF NOT EXIST *.NFO & z=%1z (
ECHO It appears you haven't run vid. export yet!
ping localhost -n 5 >nul
exit /B
)
-
if not exist *.nfo (
if "%1z"=="z" (
ECHO It appears you haven't run vid. export yet!
ping localhost -n 5 >nul
exit /B
)
)
not sure what you mean by =z, but this should only activate if both statements return true.
-
its my solution and likely the wrong 1. This is TRUE only when no %1 exists, ie 'z'=='z'. what is right way IF exist %1==""?
aaahhh, wouldnt have thought of nesting loops. thanx
-
is fine but not processing %1, whats wrong?
@cls
@ECHO Off
ECHO +-----------------------------+
ECHO :XBMC NFO TO DIR Creator V2.0:
ECHO +-----------------------------+
ECHO.
IF not EXIST NFO2DIR.TXT (
ECHO Ensure yourv'e read nfo2dir.txt before you run, Press ^^C if you want to abort. .
echo Because WARNING: This will irreversibly, alter disk structure!!!
ping localhost -n 5 >nul
) else (
START /max notepad NFO2DIR.TXT
)
if not exist *.nfo (
if "%1z"=="z" (
ECHO It appears you haven't run vid. export yet!
ping localhost -n 5 >nul
exit /B
)
)
echo Please wait. . DON'T INTERRUPT!!
ping localhost -n 5 >nul
for %%a in (*.NFO) do md "%%~na" & move /y "%%~na.*" "%%~na" & move /y "%%~na-fanart.*" "%%~na" & move /y "%
%~na-poster.*" "%%~na" & move /y "%%~na-thumb.*" "%%~na"
if EXIST extrathumbs (
rd /s /q extrathumbs
)
if EXIST extrafanart (
rd /s /q extrafanart
echo extrafanart and extrathumbs dir. deleted
) ELSE (
echo extrafanart or extrathumbs dir. not found. . .
)
if not x==%1x goto end
set a=%1
setlocal EnableDelayedExpansion
set b=1
:loop.countChar.2
call set c=%%a:~!b!,1%%
if "%c%"=="" goto end
set /a b+=1
goto loop.countChar.2
:end
echo Stacked files may exist, no switches given, read manual
ping localhost -n 5 >nul
dir /p
exit /b
set end=-%b%
for %%a in (*%1.*) do call :next "%%a"
goto :EOF
:next
set "var=%~n1"
call set "var=%%var:~0,%end%%%"
md "%var%" 2>nul
move "%~1" "%var%" >nul
@cls
echo Operation Completed Successfully.
ping localhost -n 5 >nul
-
is there a reason that it uses %1z and not %1 in the if statement? The only thing I can think of for z would be %:~z1 which is file size, and I don't think that's what you were looking for. the if statement would only work if "%1%"=="", or is undefined.
oh, and if %1 is more than one word, then you need to put quotes around it in all your statements, otherwise some will not run properly.
-
is there a reason that it uses %1z and not %1 in the if statement? The only thing I can think of for z would be %:~z1 which is file size, and I don't think that's what you were looking for. the if statement would only work if "%1%"=="", or is undefined.
oh, and if %1 is more than one word, then you need to put quotes around it in all your statements, otherwise some will not run properly.
when theres not a %1 given, ie its blank z or x,y,z whatever you give it, z==z, so a TRUE condition is met.
just wanted foxidrive and lemonilla to double check their respective code. post insertion they worked fine, so must be a syntaxy/typo thing going on.
-
is fine but not processing %1, whats wrong?
@cls
@ECHO Off
ECHO +-----------------------------+
ECHO :XBMC NFO TO DIR Creator V2.0:
ECHO +-----------------------------+
ECHO.
IF not EXIST NFO2DIR.TXT (
ECHO Ensure yourv'e read nfo2dir.txt before you run, Press ^^C if you want to abort. .
echo Because WARNING: This will irreversibly, alter disk structure!!!
ping localhost -n 5 >nul
) else (
START /max notepad NFO2DIR.TXT
)
if not exist *.nfo (
if "%1z"=="z" (
ECHO It appears you haven't run vid. export yet!
ping localhost -n 5 >nul
exit /B
)
)
echo Please wait. . DON'T INTERRUPT!!
ping localhost -n 5 >nul
for %%a in (*.NFO) do md "%%~na" & move /y "%%~na.*" "%%~na" & move /y "%%~na-fanart.*" "%%~na" & move /y "%
%~na-poster.*" "%%~na" & move /y "%%~na-thumb.*" "%%~na"
if EXIST extrathumbs (
rd /s /q extrathumbs
)
if EXIST extrafanart (
rd /s /q extrafanart
echo extrafanart and extrathumbs dir. deleted
) ELSE (
echo extrafanart or extrathumbs dir. not found. . .
)
if not x==%1x goto end <-- may want to change this to 'if "x"=="%1x" goto end' that way, if %1 is more than one word, it wont get messed up
set a=%1
setlocal EnableDelayedExpansion
set b=1
:loop.countChar.2
call set c=%%a:~!b!,1%%
if "%c%"=="" goto end
set /a b+=1
goto loop.countChar.2
:end
echo Stacked files may exist, no switches given, read manual
ping localhost -n 5 >nul
dir /p
exit /b
set end=-%b%
for %%a in (*%1.*) do call :next "%%a"
goto :EOF
:next
set "var=%~n1"
call set "var=%%var:~0,%end%%%"
md "%var%" 2>nul
move "%~1" "%var%" >nul
@cls
echo Operation Completed Successfully.
ping localhost -n 5 >nul
That's the only thing I can see, but there may be more that i'm missing. Hard to test without the files. If it still doesn't work, try dropping pause's between the chunks of code to find which one is causing the error.
-
when theres not a %1 given, ie its blank z or x,y,z whatever you give it, z==z, so a TRUE condition is met.
It will fail with quoted terms. That technique from MSDOS days should be replaced with this in windows:
if "%~1"==""
-
Thanks for the correction foxidrive, I knew it looked funny, but couldn't figure out why.
out of curiosity, why would it fail with quotes? Does it have something to do with not replacing %1? It seemed to work when I used %a% in cmd.
-
In this instance the %1 will contain quotes when long filename elements are used in %1.
if "%1z"=="z"
So that line will expand to this which is a mess and the long filename elements like spaces and & will cause an error message:
if ""my file.txt"z"=="z"
-
@cls
::@ECHO Off
COLOR 1F
ECHO +--------------------------------+
ECHO :XBMC NFO TO DIR Creator V2.00. :
ECHO :(c)2012,2013, by the 'Strokeman':
ECHO +--------------------------------+
ECHO.
IF not EXIST NFO2DIR.TXT (
ECHO Ensure your've read nfo2dir.txt before you run, Press ^^C if you want to abort. .
echo Because WARNING: This will irreversibly, alter disk structure!!!
ping localhost -n 5 >nul
) else (
START /max notepad NFO2DIR.TXT
)
goto miss
if not exist *.nfo (
echo.
ECHO It appears you haven't run vid. export yet!
ping localhost -n 5 >nul
exit /B
)
:miss
if "%~1"=="" (
echo.
echo Stacked video files MAY be present, no
echo commandlines given, continuing anyway. .
ping localhost -n 5 >nul
)
echo.
echo Please wait. . DON'T INTERRUPT!!
ping localhost -n 5 >nul
for %%a in (*.NFO) do md "%%~na" & move /y "%%~na.*" "%%~na" >nul
if exist (*-fanart.*) (
for %%a in (*.) do (
move /y "%%~na-fanart.*" "%%~na" >nul
)
)
if exist (*-poster.*) (
for %%a in (*.) do (
move /y "%%~na-poster.*" "%%~na" > nul
)
)
if exist (*-landscape.*) (
for %%a in (*.) do (
move /y "%%~na-landscape.*" "%%~na" >nul
)
)
if exist (*-thumb.*) (
for %%a in (*.) do (
move /y "%%~na-thumb.*" "%%~na" >nul
)
)
if EXIST extrathumbs (
rd /s /q extrathumbs
)
if EXIST extrafanart (
rd /s /q extrafanart
echo.
echo extrafanart and extrathumbs dir. deleted
) ELSE (
echo.
echo extrafanart or extrathumbs dir. not found. . .
)
set a=%1
setlocal EnableDelayedExpansion
set b=1
:loop.countChar.2
call set c=%%a:~!b!,1%%
if "%c%"=="" goto end
set /a b+=1
goto loop.countChar.2
:end
echo.
echo The following is a listing of files not yet processed
echo it dosent show your newly created dir. structure!. . .
echo.
dir /a-d-h
ping localhost -n 3 >nul
goto :eof
set end=-%b%
for %%a in (*%1.*) do call :next "%%a"
goto end
if not "%~1"=="" (
:next
set "var=%~n1"
call set "var=%%var:~0,%end%%%"
md "%var%" 2>nul
echo moving %1 to "%var%"
move "%~1" "%var%" >nul
)
:skip
echo.
echo Operation Completed Successfully, you will now have to update Library, After
echo that, please run artwork downloader, then enable extrafanart in chosen skin.
ping localhost -n 5 >nul
i dont get it, have looked at it a million times. if i put in a %1 its fine, but with no commandline it gets stuck in the red section, incrementing to affinity, till i ^c it?
-
Looking only at the red bit:
goto end
:next
set "var=%~n1"
call set "var=%%var:~0,%end%%%"
md "%var%" 2>nul
echo moving %1 to "%var%"
move "%~1" "%var%" >nul
goto :EOF
-
bugger, hl the wrong section, sorry!
set a=%1
setlocal EnableDelayedExpansion
set b=1
:loop.countChar.2
call set c=%%a:~!b!,1%%
if "%c%"=="" goto end
set /a b+=1
goto loop.countChar.2
goto :EOF
-
The characters % and ^ in filenames might cause problems.
@echo off
set "a=%~1"
set b=0
:loop.countChar.2
call set "c=%%a:~%b%,1%%"
if "%c%"=="" goto :end
set /a b+=1
goto loop.countChar.2
:end
echo %b%
pause
-
i just wrapped it in if not exist "%~1" (...code....). so it skips that section if no %1 specified, but thats just avoiding the prob, so will try your way.
thanks so far, you guys rock! theres some issues still, but have other 'work', so will have 2 shelve it for now :'(. but ill be back.