Hi,
I am trying to copy files from one several thousand folders to a single folder based on a string present in the files names. The code I'm using is below:
foreach folder in `branchlist' {
cd "$path"
cd "`folder'"
global branch_code `folder'
local datelist: dir . dirs *, respectcase
foreach folder in `datelist' {
cd "$path"
cd "$branch_code"
cd "`folder'
global date_code `folder'
local filelist: dir . files *, respectcase
foreach ele in `filelist' {
local newname = "$branch_code" + "_" + "$date_code" + "_" + "`ele'"
shell rename "`ele'" "`newname'"
if strpos("`newname'","LoansBalanceFile-lond2390.txt")>0 {
copy "`newname'" `" D:\Bank_Loans\Loan data\loan_balance"`newname'" "'
}
}
}
}
I am having trouble with the copy command. I understand it has something to do with the quotes and the macro referencing. But I'm struggling to figure it out. Any help would be much appreciated.
Jefferson
I am trying to copy files from one several thousand folders to a single folder based on a string present in the files names. The code I'm using is below:
foreach folder in `branchlist' {
cd "$path"
cd "`folder'"
global branch_code `folder'
local datelist: dir . dirs *, respectcase
foreach folder in `datelist' {
cd "$path"
cd "$branch_code"
cd "`folder'
global date_code `folder'
local filelist: dir . files *, respectcase
foreach ele in `filelist' {
local newname = "$branch_code" + "_" + "$date_code" + "_" + "`ele'"
shell rename "`ele'" "`newname'"
if strpos("`newname'","LoansBalanceFile-lond2390.txt")>0 {
copy "`newname'" `" D:\Bank_Loans\Loan data\loan_balance"`newname'" "'
}
}
}
}
I am having trouble with the copy command. I understand it has something to do with the quotes and the macro referencing. But I'm struggling to figure it out. Any help would be much appreciated.
Jefferson
Comment