Need to do a for loop for file extention

August 17, 2011 at 20:41:00
Specs: Windows XP SP3, 4000+ / 2gb DDR
Hi having a problem trying to find if a new file exists with a specific extension in set directory and all sub-directory's

I borrowed a piece of code from another page on this site but can't get it to work HOW I want, basically while the file is being uploaded to my server it has a different file extension until completed, once complete it's file extension is changed to the correct format so need my code to loop until the file is ready to move, this piece of code just does the checking to see if it exists, but checking in unknown sub directories is my problem.

Any suggestions ?

:: START TEST FOR NEW FILE EXTENSION BATCH

@echo off
:: SET THE MAPPED NETWORK DRIVE LETTER HERE
set drive=T:
:: ****************************************
setlocal enabledelayedexpansion
:repeat
for /f "tokens=*" %%a in ('dir /s /b '*.new' %%drive%%') do (
echo "%%a" && goto new-file
for %%f in ("%%a\*.zip") do (
echo "%%f" && goto ready
)
)


:new-file
echo NEW FILE Being Uploaded
sleep 60
goto repeat
PAUSE
GOTO END

:ready
echo ready
PAUSE
GOTO COMMANDS

:COMMANDS
:: do stuff here

:END
endlocal

:: END TEST FOR NEW FILE EXTENSION BATCH


See More: Need to do a for loop for file extention

Report •


#1
August 22, 2011 at 01:42:31
I am trying to get this to work but for some reason it won't what's wrong ? I abandoned the for loop idea could not get it working either :(

:: start of batch
@echo off
setlocal enabledelayedexpansion
:: SET THE MAPPED NETWORK DRIVE LETTER HERE
set drive=T:
set extension=*.exe
:: ****************************************
goto find
:: ----------------------------------------
:pending
echo.
echo A file ATTRIBUTE of %found% is currently being Uploaded
echo for later migration to Read Only directories.
sleep 6
cls

:: ****************************************
:find
:: ----------------------------------------
echo FIND STRING ONE
echo.
dir %drive% /s | find "%extension%" >>%drive%\tmp.txt
set /p found=<%drive%\tmp.txt
del %drive%\tmp.txt
IF NOT "%found%"=="" echo %found% && goto pending
:: call %found%.bat
echo.
pause
cls
:: ****************************************
exit
endlocal

:: end of batch


Report •
Related Solutions


Ask Question