Page 2 of 3
Re: script to copy sevaral folder contents into one folder
Posted: 05 Nov 2011 12:57
by highend
Is it reproducable (same file, produces the same error)?
I can't see anything wrong inside the script.
Re: script to copy sevaral folder contents into one folder
Posted: 05 Nov 2011 15:03
by kotlmg
error is repeating in other systems also. i have checked in win7 32 bit and win 7 64 bit systems, but the error is popping up again.
case : i have created one folder called test. within test folder i have file ClavierHelp.html.pdf
and folder ClavierHelp.html - Copy (2). folder ClavierHelp.html - Copy (2) has ClavierHelp.html - Copy (2).pdf file. when i have used your code on test folder, the following errors popped up.
Re: script to copy sevaral folder contents into one folder
Posted: 05 Nov 2011 16:05
by highend
Code: Select all
/* 05.11.2011, Move files and contents of folders to a different (new) folder
::load "<xyscripts>\.snippets\MoveToNewDestination.xys";
*/
setting('BackgroundFileOps', 0);
$destination = inputfolder( ,select destination folder to move to);
$FolderList = get("SelectedItemsPathNames", "|");
foreach($FLD, $FolderList)
{
if (exists($FLD)==2)
{
$content = folderreport("files", "r", $FLD, "r", , "|");
foreach($Item, $content)
{
moveto $destination, $Item;
}
} else {
moveto $destination, $FLD;
}
delete 1, 0, $FLD;
}
Re: script to copy sevaral folder contents into one folder
Posted: 05 Nov 2011 16:28
by kotlmg
wonderful sir, the code is perfectly working as i desired. you are really a genius.
Re: script to copy sevaral folder contents into one folder
Posted: 13 Nov 2011 14:56
by kotlmg
i have modified the above code to type the destination folder as follows. it is working. now can i have the two options ie. either browse or type the path in this code.
/* 05.11.2011, Move files and contents of folders to a different (new) folder
::load "<xyscripts>\.snippets\MoveToNewDestination.xys";
*/
setting('BackgroundFileOps', 0);
$destination = input("Enter target path");
$FolderList = get("SelectedItemsPathNames", "|");
foreach($FLD, $FolderList)
{
if (exists($FLD)==2)
{
$content = folderreport("files", "r", $FLD, "r", , "|");
foreach($Item, $content)
{
moveto $destination, $Item;
}
} else {
moveto $destination, $FLD;
}
delete 1, 0, $FLD;
}
Re: script to copy sevaral folder contents into one folder
Posted: 14 Nov 2011 11:21
by zer0
Can you please use code tags and indent as appropriate? Makes code easier to read and understand.
Re: script to copy sevaral folder contents into one folder
Posted: 15 Nov 2011 04:10
by kotlmg
i have added two options. 1. Browse for folder, 2. Type Path. With the help of stefan sir's code i could modify the above code as follows.
Code: Select all
/* 18.11.2011, Move files and contents of folders to a different (new) folder
::load "<xyscripts>\.snippets\MoveToNewDestination.xys";
*/
$Methode = inputselect(Choose methode for Moving files:, "Browse|Type Path", , 2);
if ($Methode=="Type Path"){
setting('BackgroundFileOps', 0);
$destination = input("Enter target path");
$FolderList = get("SelectedItemsPathNames", "|");
foreach($FLD, $FolderList)
{
if (exists($FLD)==2)
{
$content = folderreport("files", "r", $FLD, "r", , "|");
foreach($Item, $content)
{
moveto $destination, $Item;
}
} else {
moveto $destination, $FLD;
}
delete 1, 0, $FLD;
}
}
else{
setting('BackgroundFileOps', 0);
$destination = inputfolder( ,select destination folder to move to);
$FolderList = get("SelectedItemsPathNames", "|");
foreach($FLD, $FolderList)
{
if (exists($FLD)==2)
{
$content = folderreport("files", "r", $FLD, "r", , "|");
foreach($Item, $content)
{
moveto $destination, $Item;
}
} else {
moveto $destination, $FLD;
}
delete 1, 0, $FLD;
}
}
the above code i am using regularly. it has made my day.
Re: script to copy sevaral folder contents into one folder
Posted: 18 Nov 2011 05:11
by Zardoz2293
kotlmg wrote:i have added two options. 1. Browse for folder, 2. Type Path. With the help of stefan sir's code i could modify the above code as follows.
Code: Select all
/* 18.11.2011, Move files and contents of folders to a different (new) folder
::load "<xyscripts>\.snippets\MoveToNewDestination.xys";
*/
...
Kotlmg, consider using the revised code below:
Code: Select all
/* 18.11.2011, Move files and contents of folders to a different (new) folder
::load "<xyscripts>\.snippets\MoveToNewDestination.xys";
*/
$Methode = inputselect(Choose methode for Moving files:, "Browse|Type Path", , 2);
if ($Methode=="Type Path"){
$destination = input("Enter target path");
} else {
$destination = inputfolder( ,select destination folder to move to);
}
setting('BackgroundFileOps', 0);
$FolderList = get("SelectedItemsPathNames", "|");
foreach($FLD, $FolderList)
{
if (exists($FLD)==2)
{
$content = folderreport("files", "r", $FLD, "r", , "|");
foreach($Item, $content)
{
moveto $destination, $Item;
}
} else {
moveto $destination, $FLD;
}
delete 1, 0, $FLD;
}
Re: script to copy sevaral folder contents into one folder
Posted: 18 Nov 2011 09:50
by kotlmg
thanks Zardoz2293. your code is perfectly working.
Re: script to copy sevaral folder contents into one folder
Posted: 14 May 2012 16:28
by Steel
Hello,
I would like to use this script but I don't want it to delete anything but just to move content: is it possible?
Thank you.
Re: script to copy sevaral folder contents into one folder
Posted: 14 May 2012 16:37
by highend
Delete the delete... line?!?
Re: script to copy sevaral folder contents into one folder
Posted: 14 May 2012 18:22
by Steel
highend wrote:Delete the delete... line?!?
If I knew what to do or understood coding I wouldn't be asking in the first place.
What about those } at the end?
Do they remain so that it looks like this?
} else {
moveto $destination, $FLD;
}
delete 1, 0, $FLD;
}
Thank you
Re: script to copy sevaral folder contents into one folder
Posted: 14 May 2012 19:07
by highend
Re: script to copy sevaral folder contents into one folder
Posted: 14 May 2012 19:40
by Steel
highend wrote:Do they remain?
Yeah.
Thanks but proving I am no expert I cannot seem to make it work.
I placed a button on the Toolbar and in "On Click" I placed the code minus the delete 1, 0, $FLD;
When I click on the button I get a dropdown with some of the code: what am I doing wrong?
Thank you
Re: script to copy sevaral folder contents into one folder
Posted: 14 May 2012 19:53
by highend
Probably because you have copied one of the later postings that showed the code in code tags.
Each line of the code must be preceeded with at least a space (or in my case: a tab) as a general rule
(excluding the first line, comments or subcode).
The last two code postings don't obey this rule and you have to reindent it yourself.