I am using this to get the latest file from a folder:
@echo offcd /d C:\cdir /od /b > %temp%\latest.txtfor /F %%a in (%temp%\latest.txt) do set LATEST_FILE=%%ac:\z\ClipCopy.exe "c:\c\%LATEST_FILE%""c:\c\%LATEST_FILE%"
but it fails to worok if there is a space in the file name
is there a way to overcome this? I've googled ... I'm overlooking something ..
please advise ..
* also is there a way to accommodate for foreign characters - in above or bellow scripts .. say file names with " " (failes to show up - here is a string https://www.google.com/search?q=%D0%98%D1%81%D0%BA%D1%83%D1%81%D1%81%D1%82%D0%B2%D0%BE+%D0%B3%D0%BE%D0%B2%D0%BE%D1%80%D0%B8%D1%82%D1%8C
will be out of luck :/
=====================
one alternative way I thought is to replace all file names that have spaces with with underscores
and run that before my script
I tried these scripts - but to no avail
@echo offcd /d C:\y\_captures for /F "delims=" %%A in ('dir /b /a-d /s "* *.*"') do call :sub "%%A" goto :eof :sub set "_fn=%~nx1" echo ren %1 "%_fn: =_%" >> C:\z\results.txt from http://social.technet.microsoft.com/Forums/en-US/419bf7b4-9208-4c6a-bc27-288116f6954b/batch-file-to-replace-spaces-with-underscores?forum=ITCG
@echo offcd /d C:\y\_captures setlocal enabledelayedexpansionfor %%a in (*_*) do ( set file=%%a echo "!file" ren "!file!" "!file:_= !") cd C:\z from http://stackoverflow.com/questions/14387780/batch-file-to-replace-underscores-with-spaces-in-a-filename
@echo off & setlocal enableextensions set targetFolder=C:\y\_captures pushd "%targetFolder%" for /f "tokens=*" %%f in (' dir /b /a-d-s "%targetFolder%\* *.*"') do ( call :ProcessOneFile "%%~ff") popd endlocal & goto :EOF :: :ProcessOneFile setlocal enableextensions disabledelayedexpansion set filename="%~nx1" set filename=%filename: =_% echo ren %1 %filename% endlocal & goto :EOFfrom http://www.netikka.net/tsneti/info/tscmd166.htm
====================
what do you see..
what do you think?
thank you..
↧