Batch file help
Moderator: DosItHelp
Re: Batch file help
What problem do you still have? You said it finds the file.
If it is still returning 'File not found' then some directories may not have any *.mdb *.mde files in them. It should still process the ones where it does have those file types.
If it is still returning 'File not found' then some directories may not have any *.mdb *.mde files in them. It should still process the ones where it does have those file types.
Re: Batch file help
Hi, the problem i'm having is i want the batch file to scan sub-directories.
The rest is fine...
Echo off
set flag=
for /f "skip=3 tokens=1-3,*" %%a IN ('dir *.mdb *.mde /a-d /tc' ) do (
if /i "%%d"=="bytes" set flag=1
if not defined flag if not "%%d"=="" (
echo File Name : "%%d"
echo File Extension : %%~xd
echo File Size : %%c
echo File Creation Date : %%a %%b
echo Fully Qualified Path : "%%~fd"
ECHO Last-Modified Date : "%%~td"
)
) >>all.txt
pause
The rest is fine...
Echo off
set flag=
for /f "skip=3 tokens=1-3,*" %%a IN ('dir *.mdb *.mde /a-d /tc' ) do (
if /i "%%d"=="bytes" set flag=1
if not defined flag if not "%%d"=="" (
echo File Name : "%%d"
echo File Extension : %%~xd
echo File Size : %%c
echo File Creation Date : %%a %%b
echo Fully Qualified Path : "%%~fd"
ECHO Last-Modified Date : "%%~td"
)
) >>all.txt
pause
Last edited by gbeer7 on 29 Mar 2012 08:00, edited 1 time in total.
Re: Batch file help
I'm sorry but I can't help unless you tell me what YOU see when running the batch files.
One batch file is for scanning a folder. You say it works.
The other batch file will use it to scan each folder in a subdirectory tree.
Please post the second batch file you are using too.
One batch file is for scanning a folder. You say it works.
The other batch file will use it to scan each folder in a subdirectory tree.
Please post the second batch file you are using too.
Re: Batch file help
OK the details i see from the above script is what i want, but I want it to scan sub-directories not just the local path. Does that makes sense ?
I was using second batch someone supplied on this post, but it doesn't work, doesn't scan the folders for *.mde and *.mdb.
basically it just keeps pushing out file not found all done the screen and never stops. It is seeing the 2nd batch file.
I was using second batch someone supplied on this post, but it doesn't work, doesn't scan the folders for *.mde and *.mdb.
basically it just keeps pushing out file not found all done the screen and never stops. It is seeing the 2nd batch file.
Re: Batch file help
I supplied that second batch file too. It should work...
Post that 2nd batch file that you are using too please.
Post that 2nd batch file that you are using too please.
Re: Batch file help
Sorry matey but you are doing something wrong. The 2nd batch file works fine.
If you don't post both the batch files that you are using then we can't help, because we can't see your computer and what you are doing.
If you don't post both the batch files that you are using then we can't help, because we can't see your computer and what you are doing.
Re: Batch file help
Hi,
here is script one,
@echo off
for /f "delims=" %%a in ('dir /ad/b/s') do (
pushd "%%a"
call "E:\UserData\second.bat"
popd
)
Which then calls script two,
Echo off
set flag=
for /f "skip=3 tokens=1-3,*" %%a IN ('dir *.mdb *.mde /a-d /tc') do (
if /i "%%d"=="bytes" set flag=1
if not defined flag if not "%%d"=="" (
echo File Name : "%%d"
echo File Extension : %%~xd
echo File Size : %%c
echo File Creation Date : %%a %%b
echo Fully Qualified Path : "%%~fd"
ECHO Last-Modified Date : "%%~td"
echo.
)
) >>all.txt
It just pumps "file cannot be found" , I let it run through for a while and it didnt find any *mdb or *mde files and i know for sure there are some in the directories its looking.
Thank you for you time on this.
here is script one,
@echo off
for /f "delims=" %%a in ('dir /ad/b/s') do (
pushd "%%a"
call "E:\UserData\second.bat"
popd
)
Which then calls script two,
Echo off
set flag=
for /f "skip=3 tokens=1-3,*" %%a IN ('dir *.mdb *.mde /a-d /tc') do (
if /i "%%d"=="bytes" set flag=1
if not defined flag if not "%%d"=="" (
echo File Name : "%%d"
echo File Extension : %%~xd
echo File Size : %%c
echo File Creation Date : %%a %%b
echo Fully Qualified Path : "%%~fd"
ECHO Last-Modified Date : "%%~td"
echo.
)
) >>all.txt
It just pumps "file cannot be found" , I let it run through for a while and it didnt find any *mdb or *mde files and i know for sure there are some in the directories its looking.
Thank you for you time on this.
Last edited by gbeer7 on 30 Mar 2012 01:31, edited 1 time in total.
Re: Batch file help
gbeer7 wrote:Hi,
here is script one,
@echo off
for /f "delims=" %%a in ('dir /ad/b/s') do (
pushd "%%a"
call "E:\UserData\second.bat"
popd
)
Which then calls script two,
@Echo off
set flag=
echo "%cd%"
for /f "skip=3 tokens=1-3,*" %%a IN ('dir *.mdb *.mde /a-d /tc 2^>nul ') do (
if /i "%%d"=="bytes" set flag=1
if not defined flag if not "%%d"=="" (
echo File Name : "%%d"
echo File Extension : %%~xd
echo File Size : %%c
echo File Creation Date : %%a %%b
echo Fully Qualified Path : "%%~fd"
ECHO Last-Modified Date : "%%~td"
echo.
)
) >>c:\all.txt
It just pumps "file cannot be found" , I let it run through for a while and it didnt find any *mdb or *mde files and i know for sure there are some in the directories its looking.
Thank you for you time on this.
Make the changes above and try it.
You will find "all.txt" files in all the folders you ran it on with *.mdb *.mde files, when you were testing it.
Re: Batch file help
Thank you.
Just run that, its now displaying this :-
File Name : "Stuff\Leavers"
File Extension :
File Size : E:\UserData\*\*\*
File Creation Date : Directory of
Fully Qualified Path : "E:\UserData\*\*\*\*\*\*"
Last-Modified Date : ""
I've added * to blank out the folder names. So its not putting the MDB or MDE file name, File extension, size, creation and last modifiled.
Just run that, its now displaying this :-
File Name : "Stuff\Leavers"
File Extension :
File Size : E:\UserData\*\*\*
File Creation Date : Directory of
Fully Qualified Path : "E:\UserData\*\*\*\*\*\*"
Last-Modified Date : ""
I've added * to blank out the folder names. So its not putting the MDB or MDE file name, File extension, size, creation and last modifiled.
Re: Batch file help
Is this in c:\all.txt ?
I didn't change the logic at all - the second.bat file doesn't seem to be working for the files.
Can you run second.bat itself in a folder with *.mdb *.mde files?
I didn't change the logic at all - the second.bat file doesn't seem to be working for the files.
Can you run second.bat itself in a folder with *.mdb *.mde files?
Re: Batch file help
Try this as second.bat
Code: Select all
@Echo off
set flag=
echo "%cd%"
for /f "skip=2 tokens=1-3,*" %%a IN ('dir *.mdb *.mde /a-d /tc 2^>nul ^|find /v /i " Directory of "') do (
if /i "%%d"=="bytes" set flag=1
if not defined flag if not "%%d"=="" (
echo File Name : "%%d"
echo File Extension : %%~xd
echo File Size : %%c
echo File Creation Date : %%a %%b
echo Fully Qualified Path : "%%~fd"
ECHO Last-Modified Date : "%%~td"
echo.
)
) >>c:\all.txt
Re: Batch file help
Here is a single batch file version. The logic is changed in the subroutine to simplify the exercise. It still requires 24 hour time to use the right tokens.
Code: Select all
@echo off
for /f "delims=" %%a in ('dir /ad /s /b') do call :subroutine "%%a"
pause
goto :EOF
:subroutine
pushd "%~1"
set flag=
echo "%cd%"
for /f "tokens=1-3,*" %%a IN ('dir *.mdb *.mde /a-d /tc 2^>nul ^|find ":" ^|find /v /i " Directory of "') do (
echo File Name : "%%d"
echo File Extension : %%~xd
echo File Size : %%c
echo File Creation Date : %%a %%b
echo Fully Qualified Path : "%%~fd"
echo Last-Modified Date : "%%~td"
echo.
) >>c:\all.txt
popd
Re: Batch file help
Hi, just running the all-in-one now. I appricate you taking the time with this.
Re: Batch file help
Amazing, thank you ! it works a treat. Thanks for you time and effort, very kind.
Re: Batch file help
That's good, and you're welcome.