Source language: Translate to:

FileCopy and "Access Denied!"

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

FileCopy and "Access Denied!"

Postby billc » Fri Jul 30, 2010 2:13 pm

Hi, all.

I'm new to the forum but not to NeoBook. I've fiddled around with it for years but have just gotten really serious about using it.

I've been working on a small app that I can use to select from several backup options, as in, back up to thumb drive, back up to another location on my hard drive, and copy work files to and from my hard drive and a thumb drive.

The code looked to me to be pretty straightforward but when I actually ran it, no matter which of my selections I chose, when the files should have been copied, I got the "Access Denied!" error message.

I've searched the forum in vain for a simple explanation and all I've found are references to using the FileOpenBox action, which isn't really what I wanted to do.

Surely NeoBook has some method of EASILY copying files from one location to another, no? Like using FileCopy with Windows wildcards (which is what I was trying to do)?

Does the fact that I'm using Windows 7 make a difference?

Does the fact that, with a thumb drive, no matter how many times I set a directory to be write-able, it still changes back to "Read Only"? But that's just with thumb drives and the hard drive files won't copy either (same error message).

Here's the code I've been trying to make work (this one specifically to copy my work files from a directory on my hard drive to a thumb drive that could be in any of four ports:

FolderExists "F:\Personal" "[FolderExistsF]"
FolderExists "G:\Personal" "[FolderExistsG]"
FolderExists "I:\Personal" "[FolderExistsI]"
FolderExists "J:\Personal" "[FolderExistsJ]"
If "[FolderExistsF]" "=" "True"
GoToLine "ThumbF"
EndIf
If "[FolderExistsG]" "=" "True"
GoToLine "ThumbG"
EndIf
If "[FolderExistsI]" "=" "True"
GoToLine "ThumbI"
EndIf
If "[FolderExistsJ]" "=" "True"
GoToLine "ThumbJ"
EndIf
AlertBox "Drive Incorrect or Inaccessible" "The thumb drive is located in some other location than F, G, I, or J."
Exit "" ""

:ThumbF
FileCopy "F:\TreePad Data Files\*.*" "D:\TreePad Data Files\*.*"
FileCopy "F:\Work NeoBook Pubs\*.*" "D:\NeoBook Pubs\*.*"
AlertBox "Files Copied" "Files have been successfully copied from the F thumb to the D Drive."
Exit "" ""

:ThumbG
FileCopy "G:\TreePad Data Files\*.*" "D:\TreePad Data Files\*.*"
FileCopy "G:\Work NeoBook Pubs\*.*" "D:\NeoBook Pubs\*.*"
AlertBox "Files Copied" "Files have been successfully copied from the G thumb to the D Drive."
Exit "" ""

:ThumbI
FileCopy "I:\TreePad Data Files\*.*" "D:\TreePad Data Files\*.*"
FileCopy "I:\Work NeoBook Pubs\*.*" "D:\NeoBook Pubs\*.*"
AlertBox "Files Copied" "Files have been successfully copied from the I thumb to the D Drive."
Exit "" ""

:ThumbJ
FileCopy "J:\TreePad Data Files\*.*" "D:\TreePad Data Files\*.*"
FileCopy "J:\Work NeoBook Pubs\*.*" "D:\NeoBook Pubs\*.*"
AlertBox "Files Copied" "Files have been successfully copied from the J thumb to the D Drive."
Exit "" ""

As you can see, I'm no hotshot programmer so this is probably a very convoluted way to try to make NeoBook work for me so I'm all sorts of open to other suggestions.

The goal is to have the app recognize which port has the thumb drive, then copy all of the files in the two directories listed from the hard drive to the thumb drive.

Any help you exports can offer will be highly appreciated.

bc
billc
 
Posts: 28
Joined: Fri Jul 30, 2010 1:46 pm

Postby Neosoft Support » Mon Aug 02, 2010 11:04 am

The FileCopy action does not accept wildcards (*.*) which is causing the access denied error message.

Try this instead:

Code: Select all
SetVar "[SourceDrive]" ""

FolderExists "F:\Personal" "[FolderExistsF]"
FolderExists "G:\Personal" "[FolderExistsG]"
FolderExists "I:\Personal" "[FolderExistsI]"
FolderExists "J:\Personal" "[FolderExistsJ]"
If "[FolderExistsF]" "=" "True"
  SetVar "[SourceDrive]" "F:"
EndIf
If "[FolderExistsG]" "=" "True"
  SetVar "[SourceDrive]" "G:"
EndIf
If "[FolderExistsI]" "=" "True"
  SetVar "[SourceDrive]" "I:"
EndIf
If "[FolderExistsJ]" "=" "True"
  SetVar "[SourceDrive]" "J:"
EndIf

If "[SourceDrive]" ">" ""

  FileList "[SourceDrive]\TreePad Data Files\*.*" "Files" "[FilesToCopy]"
  StrParse "[FilesToCopy]" "[#13]" "[File]" "[FileCount]"
  Loop "1" "[FileCount]" "[CopyCount]"
    FileCopy "[SourceDrive]\TreePad Data Files\[File[CopyCount]]" "D:\TreePad Data Files\"
  EndLoop
 
  FileList "[SourceDrive]\Work NeoBook Pubs\*.*" "Files" "[FilesToCopy]"
  StrParse "[FilesToCopy]" "[#13]" "[File]" "[FileCount]"
  Loop "1" "[FileCount]" "[CopyCount]"
    FileCopy "[SourceDrive]\Work NeoBook Pubs\[File[CopyCount]]" "D:\NeoBook Pubs\"
  EndLoop
 
  AlertBox "Files Copied" "Files have been successfully copied from the [SourceDrive] thumb to the D Drive."

Else
  AlertBox "Drive Incorrect or Inaccessible" "The thumb drive is located in some other location than F, G, I, or J."
EndIf

Exit "" ""
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

FileCopy and "Access Denied!"

Postby billc » Mon Aug 02, 2010 2:51 pm

Thanks so much for your reply.

I will give that a real good try.

No charge for the rhyming :lol:
billc
 
Posts: 28
Joined: Fri Jul 30, 2010 1:46 pm

FileCopy and "Access Denied!" -- follow-up

Postby billc » Fri Aug 06, 2010 1:21 pm

Well, Windows 7 (and perhaps Vista) appears to have built in a snafu for NeoBook's FileCopy command as well as the work-around that has served folks in the past (including the one offered above).

After an intense search on the Microsoft site, I discovered that the process used by Windows 7 and Vista uses a different method of copying files than that which is used by FileCopy and other routines within NeoBook. The result is that you'll consistently get an "Access Denied!" error message when you run your program.

However, after a great deal of fiddling around and testing (including testing the suggestion in the previous post), I determined that you can use the loop process (as shown in the suggested script, above) with Windows 7 so long as you do NOT have any subfolders that would normally be captured by wildcards.

That is, your file path must go all the way down until you have ONLY files and no folders.

Said another way, using "c:\directory level one\directory level two\three\etc.\filenames" as a guide, while the following will NOT work...

c:\directory level one\directory level two\*.*

...because there are folders included below "directory level two," the following WILL work...

c:\directory level one\directory level two\three\etc.\*.*

...because there are no folders below the "etc." level.

I hope this makes sense and is helpful to someone.

I also hope the programmers at NeoSoftware will provide a means to use their standard FileCopy action command (a) in Windows 7 and (b) for multiple files using wildcards. It can't be that hard, can it?

bc
billc
 
Posts: 28
Joined: Fri Jul 30, 2010 1:46 pm

Postby Neosoft Support » Mon Aug 09, 2010 10:07 am

The FileCopy action does work with Windows 7 and Vista. However, the FileCopy action will not copy folders. If you try to copy a folder, you will receive an access denied error message. FILEcopy can only be used to copy files.

If you need to copy folder and files, you will need to use something like the NeoBookFM/FTP plug-in:

http://www.neosoftware.com/neobook/modules/plugins/singlefile.php?cid=12&lid=131
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

FileCopy and "Access Denied!"

Postby billc » Mon Aug 09, 2010 10:16 pm

Hmmmm. $80 for a plug-in to copy folders - an extremely common need with Windows?

I can build a batch file for free that copies anything and everything and just call that from NeoBook. I think I'll do that.

I still think NeoBook should provide a means to copy folders along with files. It's silly not to since it's supposed to be a Windows app and work fully with Windows. But I like everything else so much that I'll continue to use NeoBook and just figure out work-arounds for it's shortcomings.

Thanks.
billc
 
Posts: 28
Joined: Fri Jul 30, 2010 1:46 pm

Postby Wrangler » Tue Aug 10, 2010 7:51 am

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: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest