1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| @echo off
mode con cols=70 lines=3 & Color 0A
Title Get FilePath with their CreationDate
Set "Target_dir=%userprofile%\Pictures\AutoSaveScreenShot\"
REM IMPORTANT Don't forget the final backslash in the path of your folder\
Call :Check_backslash %Target_dir% Target_dir
Set "LogFile=%~dpn0.csv"
If Exist "%LogFile%" Del "%LogFile%"
SetLocal EnableDelayedExpansion
@For /f "tokens=1,2 delims=:" %%a in ('Dir "%Target_dir%" /s /b /o:n /ad') do (
REM Set "Drive=%%a"
REM IMPORTANT Don't forget the final backslash in the path of your folder\
Set "Folder_Path=%%b\"
Call :Check_backslash !Folder_Path! Folder_Path
Call :Add_backSlash !Folder_Path! Folder_Path
@For /f "Tokens=1,2 Skip=1 Delims= " %%a in ('WMIC DATAFILE WHERE "PATH='!Folder_Path!'" GET CreationDate^,Caption') do (
REM The output of WMIC is unicode !
REM The trailing <CR> can be removed by passing the value through another FOR /F loop.
REM This also removes the phantom "blank" line (actually a <CR>) ie The second for /f loop
@For /f "delims=" %%f in ("%%a") do (
Set "FileName=%%~nxa"
Set "FilePath=%%a"
set "DT=%%b"
REM Convert ISO date to Date
set "DT=!DT:~0,4!_!DT:~4,2!_!DT:~6,2!_!DT:~8,2!-!DT:~10,2!-!DT:~12,2!"
Call :Scanning "!FileName!"
echo "!FileName!";"!FilePath!";"!DT!">>"!LogFile!"
)
)
)
If Exist "!LogFile!" Start "" /MAX Notepad "!LogFile!" & Exit
::---------------------------------------------------------------------
:Add_backSlash <String> <Var to Set>
Rem Subroutine to replace the simple "\" by a double "\\" into a String
Set "MyString=%1"
Set "String=\"
Set "NewString=\\"
Call Set "%2=%%MyString:%String%=%NewString%%%"
Exit /b
::---------------------------------------------------------------------
:Check_backslash
Set "datapath=%1"
IF NOT "%datapath:~-1%"=="\" SET "%2=%datapath%\"
Exit /b
::---------------------------------------------------------------------
:Scanning <file>
Cls & Color 0A
echo(
echo "%~1" ...
goto :eof
::--------------------------------------------------------------------- |
Partager