Moving everything other than latest file.

July 14, 2011 at 02:48:49
Specs: Windows 7
How to move all the files other than the latest file to a specified folder using a .bat file.

See More: Moving everything other than latest file.

Report •

#1
July 14, 2011 at 13:44:16
@echo off

for /f %%a in ('dir *.* /od /b') do (
set Latest=%%a
)
echo %Latest%

attrib %Latest% +h

move *.* TX\

attrib %Latest% -h
dir


Report •

#2
July 14, 2011 at 14:36:01
Untested. Change Copy to Move when you are satisfied with the outcome.

@echo off
cls
setlocal
if not exist "%temp%\output\" md "%temp%\output\"

pushd %temp%\input\||echo Pushd failed - job terminated.&&exit /b

for /f "skip=1 tokens=*" %%1 in ('dir /a-d /o-d /tw /b') do (
    copy "%%1" "%temp%\output\">nul
    )
popd

Dir "%temp%\output\"


Please come back & tell us if your problem is resolved.


Report •
Related Solutions


Ask Question