Copy files from subfolders to one folder based on criteria
Moderator: DosItHelp
-
- Posts: 12
- Joined: 18 Oct 2010 14:51
Copy files from subfolders to one folder based on criteria
I have a directory structure:
K:\Franchises\Seattle
K:\Franchises\New York
K:\Franchises\Boston...
and each city has hundreds of files. I need to copy all the files from each city's folder having Dominos in the filename to C:\MyLocalCopies\Dominos. Likewise all files having PizzaHut in the filename will go in C:\MyLocalCopies\PizzaHut. I have tried using a for loop with variable name but no luck so far. Would one of the smart people out there please help.
Thanks
K:\Franchises\Seattle
K:\Franchises\New York
K:\Franchises\Boston...
and each city has hundreds of files. I need to copy all the files from each city's folder having Dominos in the filename to C:\MyLocalCopies\Dominos. Likewise all files having PizzaHut in the filename will go in C:\MyLocalCopies\PizzaHut. I have tried using a for loop with variable name but no luck so far. Would one of the smart people out there please help.
Thanks
Re: Copy files from subfolders to one folder based on criter
Code: Select all
for %%a in (Dominos PizzaHut) do (
for /f "delims=" %%b in ('dir /b/s/a-d "K:\Franchises\*%%a*"') do (
xcopy /q/y "%%b" "C:\MyLocalCopies\%%a\"
))
-
- Posts: 12
- Joined: 18 Oct 2010 14:51
Re: Copy files from subfolders to one folder based on criter
Works perfectly. Thank you
-
- Posts: 12
- Joined: 18 Oct 2010 14:51
Re: Copy files from subfolders to one folder based on criter
Is there a way to delete columns N onwards in all folders in C:\MyLocalCopies\ such as C:\MyLocalCopies\PizzaHut, C:\MyLocalCopies\Unos etc. except C:\MyLocalCopies\Dominos from which I need columns M onwards deleted?
Thank you
Thank you
-
- Posts: 12
- Joined: 18 Oct 2010 14:51
Re: Copy files from subfolders to one folder based on criter
Forgot to mention...All the files in all subfolders of C:\MyLocalCopies\ are Excel files
Re: Copy files from subfolders to one folder based on criter
Don't get it. You want to delete columns in excel files using batch?
Regards
aGerman
Regards
aGerman
-
- Posts: 12
- Joined: 18 Oct 2010 14:51
Re: Copy files from subfolders to one folder based on criter
well... on MSOffice 2003 XLS files tested...
for example, N=3, M=2 (parm of StdInXlsDelCol() func)
for example, N=3, M=2 (parm of StdInXlsDelCol() func)
Code: Select all
@set @x=0 /*
@dir /b/s/a-d "C:\MyLocalCopies\*.xls"|findstr /vbc:"C:\MyLocalCopies\Dominos"|cscript //nologo /e:jscript "%~0" "StdInXlsDelCol(3)"
@dir /b/s/a-d "C:\MyLocalCopies\Dominos\*.xls"|cscript //nologo /e:jscript "%~0" "StdInXlsDelCol(2)"
@exit */
eval(WScript.Arguments.Item(0));
function StdInXlsDelCol(col) {
var str,xls = WScript.CreateObject("Excel.Application");
var fso = WScript.CreateObject("Scripting.FileSystemObject");
while (!WScript.StdIn.AtEndOfStream) {
str = WScript.StdIn.ReadLine();
WScript.Echo(str);
if (fso.FileExists(str)) {
xls.WorkBooks.Open(fso.GetAbsolutePathName(str));
xls.Application.DisplayAlerts = 0;
xls.Application.ScreenUpdating = 0;
xls.ActiveWorkbook.Sheets(1).Columns(parseInt(col)).Delete;
xls.ActiveWorkBook.Save;
xls.ActiveWorkBook.Close;
xls.Close;
}}}
Re: Copy files from subfolders to one folder based on criter
Hey guys, am trying to copy a file from one sub-subfolder to another in the command prompt. Am talking....d:\Applications\backup\supersoftware\DATA\300.xls to c:\programfiles\Royzone\Playmaker\play. Please help.
Thanks a million.
Thanks a million.