Page 1 of 1

Get modification Time and Filename

Posted: 22 Jun 2021 22:07
by sugram
Hello

I would like to determine the date of modification and the filename of a directory.
I already get the date, but with the variable %% i I get the full UNC path.
But I only need the * .pvx file names without \\Sharename\xyz\123\xxx 123\

My Test Batch

Code: Select all

for /F "delims=" %%i in ('"dir /s /b /a-d "\\Sharename\xyz\123\xxx 123\*.pvx" "') do (echo set file_date=%%~ti %%i )
I hope that someone could give me a tip here

Many Thanks

Re: Get modification Time and Filename

Posted: 23 Jun 2021 03:52
by aGerman
FOR variables support several modifiers. (run FOR /?)
Use %%~nxi to get name and extension only.

Steffen

Re: Get modification Time and Filename

Posted: 23 Jun 2021 04:16
by sugram
Hello

I read that, but unfortunately it doesn't work for me.

Code: Select all

for /F "delims=" %%i in ('"dir /s /b /a-d "\\Sharename\xyz\123\xxx 123\*.pvx" "') do (echo set file_date=%%~ti %%nxi)
output

Code: Select all

C:\Users\hrf3bw\Desktop>(echo set file_date=10.09.2020 13:21 %nxi )
set file_date=10.09.2020 13:21 %nxi

Re: Get modification Time and Filename

Posted: 23 Jun 2021 05:56
by aGerman
You forgot the tilde (~).

Steffen

Re: Get modification Time and Filename

Posted: 23 Jun 2021 21:30
by sugram
Oh yes you're right.

For the test, I had written the ~ in front of the %% and not %% ~.
I'm annoyed myself that I haven't seen it.
But thanks for the input :-)


Now it works :-)