dos - Copy Multiple Files with Same Characters to a Single File -


i have lot of files need joined. existing file naming structure 20130514abcd.txt file naming convention year, month, date, city. merge files same last 4 characters (i.e same city) one.

i able move city folder created each city. not want..

@echo off  pushd pathname /f %%f in ('dir/b/a-d *.txt') call :sub1 %%f goto :eof  :sub1 set name=%1 md %name:~9,12% move %* %name:~9,12% 

what need script equivalent c:\>copy *city.txt city.txt, city name variable.

edited: works here files you've stated.

@echo off pushd "pathname" /f "delims=" %%f in ('dir /b /a-d *.txt') call :sub1 "%%f" popd pause goto :eof  :sub1 set "name=%~1" set "cityname=%name:~8,-4%" if exist "%cityname%\" goto :eof echo processing "%cityname%" md "%cityname%" 2>nul copy /b "????????%cityname%.txt" "%cityname%\%cityname%.txt" >nul 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -