Source language: Translate to:

Copying Batch of Files to New Directory

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Copying Batch of Files to New Directory

Postby Ken1000 » Mon Jul 17, 2006 6:43 am

Hi. Can someone examine the script below and tell me why it is
not working?

My aim is to copy all files and folders which begin with the letter A
from this directory:
C:\Documents and Settings\Administrator\My Documents
into this directory:
C:\Documents and Settings\Administrator\My Documents\TestDestination

The code line is:
Run "copy C:\Documents and Settings\Administrator\My Documents\A*.* C:\Documents and Settings\Administrator\My Documents\TestDestination\" "" "RunOnce" "" ""

There are files and folders which fit this category and the destination
folder does already exist.

Thank you for your help.

Ken
Ken1000
 
Posts: 8
Joined: Sat Apr 23, 2005 10:46 pm

Postby Wrangler » Mon Jul 17, 2006 7:57 am

You are using the run action to use a dos command. DOS won't recognize filenames or folders with more than 8+3 characters, so you will need to truncate them.

Here is an article explaining this:

http://www.computerhope.com/issues/ch000209.htm
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Copying Batch of Files to New Directory

Postby dpayer » Mon Jul 17, 2006 8:18 am

Ken1000 wrote:Hi. Can someone examine the script below and tell me why it is
not working?

Ken


Are the files OPEN or being run at the time they are being copied? If so, you must address that.

D
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Gaev » Mon Jul 17, 2006 8:58 am

a) the copy command will work on long file names ... unless you are running on a Windows 3.x or 95 system ... but you need to surround names containing spaces with double quotes

b) copy does NOT handle sub-directories ... you need to use XCOPY (with /S switch)

c) After reading the help on XCOPY, try it out from the DOS prompt ... to assure yourself that you have the right syntax

d) Then, read the Help on the Run command ...

- the first parameter is for the program you want to run

- the second parameter is for "options" you want to pass to the program e.g. the source/target folders/wildcards
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby edunaway » Mon Jul 17, 2006 9:25 am

The "copy" command is built into the command line so you can't call it directly from Neobook using the Run command, but as Gaev suggested, xcopy can accomplish the same thing.

With xcopy:

Code: Select all
Run "C:\Windows\System32\xcopy" "[#34]C:\Documents and Settings\Administrator\My Documents\A*[#34] [#34]C:\Documents and Settings\Administrator\My Documents\TestDestination\[#34]" "" "RunOnce" "" ""


A couple of things to note:
1. If you use xcopy you must include a backslash at the end of the path or it will ask whether the destination is a file or directory
2. You do not need to include *.* -- a* is sufficient to copy every file starting with A

If you absolutely must use the Copy command you can do this writing the commands to a batch file and then calling the batch file with the Run command. First write the copy command to a batch file:

Code: Select all
FileWrite "copy.bat" "All" "copy [#34]C:\Documents and Settings\Administrator\My Documents\A*[#34] [#34]C:\Documents and Settings\Administrator\My Documents\TestDestination\[#34]"


Then use the Run command to call the batch file:

Code: Select all
Run "copy.bat" "" "RunOnce+Hidden" "" ""


Another note about long file names. You can reference long file names and paths from the Windows command line by using quotes "c:\long path name" -- you can also take shortcuts if you are only referencing one path, such as deleting or renaming a file by only placing the opening quotes. For example both of these will work:

del "c:\This Very Long File Name.doc"
del "c:\This Very Long File Name.doc

-eric
edunaway
 
Posts: 88
Joined: Wed May 04, 2005 9:17 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest