batch processing - Copy folders and files to a new location based on the first character of the folder or file -


i wanted have folders , files copied new location via batch based on first letter of name , keeping it's original folder structure when copied new location. (incremental)

examples:

any folder or file begins a-m or 0-9 copied n:\movies

any folder or file begins n-z copied m:\movies

i found similar script here: batch: move files folder first letter of name?

current code:

@echo off  setlocal enabledelayedexpansion  set "sourcedir=n:\"  set "destdir=m:\"  pushd "%sourcedir%"  %%a in (*) (   if /i "%%a" geq "a" if /i "%%a" lss "h" copy "%sourcedir%\%%a" "%destdir%\"   if /i "%%a" geq "h" if /i "%%a" lss "u" copy "%sourcedir%\%%a" "%destdir%\h-t\"  if /i "%%a" geq "u" (   if /i "%%a" lss "z" copy "%sourcedir%\%%a" "%destdir%\u-z\"    ) else (    set "name=%%a"     if /i "!name:~0,1!"=="z" copy "%sourcedir%\%%a" "%destdir%\u-z\"    )   ) )  popd  goto :eof  


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -