DosTips.com

A Forum all about DOS Batch
It is currently 30 Sep 2016 10:48

All times are UTC-06:00




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
PostPosted: 20 Oct 2010 15:11 
Offline

Joined: 18 Oct 2010 14:51
Posts: 12
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


Top
   
PostPosted: 20 Oct 2010 20:51 
Offline
Expert

Joined: 04 Jun 2010 20:05
Posts: 177
Location: Russia
Code:
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\"
))


Top
   
PostPosted: 21 Oct 2010 08:13 
Offline

Joined: 18 Oct 2010 14:51
Posts: 12
Works perfectly. Thank you


Top
   
PostPosted: 21 Oct 2010 10:22 
Offline

Joined: 18 Oct 2010 14:51
Posts: 12
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


Top
   
PostPosted: 21 Oct 2010 10:25 
Offline

Joined: 18 Oct 2010 14:51
Posts: 12
Forgot to mention...All the files in all subfolders of C:\MyLocalCopies\ are Excel files


Top
   
PostPosted: 21 Oct 2010 16:33 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 2326
Location: Germany
Don't get it. You want to delete columns in excel files using batch?

Regards
aGerman


Top
   
PostPosted: 21 Oct 2010 18:14 
Offline

Joined: 18 Oct 2010 14:51
Posts: 12
Yes


Top
   
PostPosted: 22 Oct 2010 02:14 
Offline
Expert

Joined: 04 Jun 2010 20:05
Posts: 177
Location: Russia
well... on MSOffice 2003 XLS files tested...
for example, N=3, M=2 (parm of StdInXlsDelCol() func)
Code:
@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;
}}}


Top
   
PostPosted: 11 Oct 2011 07:07 
Offline

Joined: 11 Oct 2011 06:29
Posts: 1
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 9 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot], Bowlardo, Google [Bot], Yahoo [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited