You are not logged in.
On each PC I have one folder:
"C:\DIR\Photo_Random-String"
and need a script that will check this whole name [Photo and Random String] and write it as %FolderName%.
I have very simple script:
C:
cd\
cd DIR
for /d %a in (Photo*) do (>nul 2>nul dir /a-d "%a\*.txt" && (set FOLDERNAME=%a))
IF EXIST %FOLDERNAME% CD %FOLDERNAME%
DEL /q *.jpg
CD..
RD %FOLDERNAME%
PAUSE
but give back this error:
"a*.txt" && (set FOLDERNAME=a)) was unexpected at this time."
What is wrong in this simple script? Or You have another idea to solve this?
Offline
Unlike at the command like, when used in a script, "%a" must take the form "%%a".
cmd | *sh | ruby | chef
Offline
I finally solved this
This is working ver:
C:
CD\
CD DIR
IF EXIST FOTO_* (CD FOTO_*) ELSE (goto END)
FOR %%I IN (.) DO SET FOLDERNAME=%%~nI%%~xI
CD\
ECHO %FOLDERNAME% Exist - Delete it !
RD /q %FOLDERNAME%
PAUSE
END
Exit
Offline
On each PC I have one folder:
"C:\DIR\Photo_Random-String"
and need a script that will check this whole name [Photo and Random String] and write it as %FolderName%.
I didn't understand your question when you posted it - it seems what you wanted to do is delete a folder if it existed.
JFTR knowing the actual details of the path\folder can make a difference to the code, with spaces etc.
Last edited by foxidrive (13 Jul 2015 20:43)
Offline