how to copy files to a folder

Help with writing and running scripts

how to copy files to a folder

Postby zhoushun » Wed Feb 06, 2008 4:59 pm

Excuse me, my english is poor.

how can i copy file to another folder?
for example c:/source/tes to t.java
how can i copy it to
d:/new??

dont like this:
UltraEdit.open("c:/source/tes to t.java")
UltraEdit.copy();
UltraEdit.newFile();
UltraEdit.parse()......
User avatar
zhoushun
Newbie
 
Posts: 2
Joined: Wed Feb 06, 2008 12:00 am

Re: how to copy files to a folder

Postby Mofi » Sat Feb 09, 2008 5:08 pm

I don't know why you do want to do a simply file copy with an UltraEdit JavaScript. Why do you now write a batch file using the copy command?

However, here is an UltraEdit script which opens the file c:\source\tes to t.java (backslashes for Windows !!!) and saves it with the same name in the directory d:\new. You have to escape a backslash in JavaScript strings with an additional backspace.

UltraEdit.perlReOn();
UltraEdit.open("c:\\source\\tes to t.java");
var FullFileName = UltraEdit.activeDocument.path;
var NameOfFile = FullFileName.replace(/([^\\]+\\)+/,"");
FullFileName = "d:\\new\\"+NameOfFile;
UltraEdit.saveAs(FullFileName);
UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: how to copy files to a folder

Postby zhoushun » Sun Feb 10, 2008 6:31 am

Thank you!
User avatar
zhoushun
Newbie
 
Posts: 2
Joined: Wed Feb 06, 2008 12:00 am

Re: how to copy files to a folder

Postby avnik » Sun Jul 12, 2009 12:47 pm

Is there any way that I can copy or move all the files from different folder to one folder? For example if I have all my folders here c:\test\ and my files are in different folders inside the test folder like this:

c:\test\1\
c:\test\2\
.
.
.
and so on

I need this so that I can run my macro on all these files at once.
User avatar
avnik
Newbie
 
Posts: 3
Joined: Sat Nov 03, 2007 11:00 pm

Re: how to copy files to a folder

Postby Mofi » Mon Jul 13, 2009 3:16 am

First it is no problem to run a macro on all files in a directory structure. Use the macro I have posted at Run Macro on all files within folder. You just have to replace the first line of the macro to:

FindInFiles Recursive "directory" "*.*" ""

My macro and your macro must be stored in the same macro file.

Second copying all files of a directory structure to one directory is an easy job when using the branch view of Total Commander. But in general following works with Windows Explorer as well as with Total Commander:

Open the root directory of the files in your file manager.
Open the File Search dialog, enter *.* as search criteria and run the search.
You have now a complete list of files in the entire directory structure.
Press Ctrl+A to select all files and while holding the left Ctrl key click on every directory name in the list. You want to copy only the files, not the directories.
Next open a second instance of your file manager (Windows Explorer) and open the target directory in this instance.
Switch back to the search result with all files already selected.
Click with left mouse button on one of the selected files and hold the mouse button.
Drag the mouse pointer over the window of the second instance of your file manager over the free space of the target directory.
Press the left Ctrl key and hold it. The mouse pointer will change and has now a small + symbol. This is important because that means the files are copied and not moved.
While still holding left Ctrl key leave the left mouse button now with the mouse pointer over the target directory window.

Your file manager copies now all the files. Hopefully all your files have a unique file name.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Scripts