Sign in to follow this  
Followers 0
sb1920alk

Copying files from a CD

13 posts in this topic

If I use FileCopy to copy a file from a CD, they're ending up as Read Only on the hard drive, and then I have to go back through and take off the Read Only attribute with FileSetAttrib. If I drag and drop the file manually, the result is not Read Only.

Am I missing something? Is there an easier way? I don't want copied files to be Read Only after they're on the hard drive.

Thanks,

Share this post


Link to post
Share on other sites



Perhaps, it's because you're using FileCopy? Try to use FileOpen(), FileRead() and FileWrite(), so you control the creation of the file and it's attribute and write using buffer which may be necessary.

Share this post


Link to post
Share on other sites

Perhaps, it's because you're using FileCopy? Try to use FileOpen(), FileRead() and FileWrite(), so you control the creation of the file and it's attribute and write using buffer which may be necessary.

I thought FileOpen, FileRead and FileWrite were only for txt files? I don't see how they would be helpful in this situation.

Share this post


Link to post
Share on other sites

You can read in binary form. Read the help file. If no, use _WinAPI_CreateFile(), _WinAPI_ReadFile() and _WinAPI_WriteFile(). This way you have more control on the streaming but more code to write.

Share this post


Link to post
Share on other sites

You can read in binary form. Read the help file. If no, use _WinAPI_CreateFile(), _WinAPI_ReadFile() and _WinAPI_WriteFile(). This way you have more control on the streaming but more code to write.

I have read the help file. I wasn't sure what the mode options other than 0, 1, and 2 were for. I thought it was something like case sensitivity. In any case, I don't see how this is simpler than using FileCopy and FileSetAttrib. I think that the fact that the files are on a CD somehow forces them to be read only because the CD is read only.

Share this post


Link to post
Share on other sites

Hi.

robocopy.exe vers. 026 (included in robocopygui -> google) has a switch to modify flags as needed, and it's exit code will tell you what happened very nicely.

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Did you try anything like what Authenticity suggested?

$File = "CD\File\Path"
$nFile = "Hard\drive\path"
$hIn = FileOpen($File, 16)
$hOut = FileOpen($nFile, 18)
FileWrite($hOut, FileRead($hIn))
FileClose($hIn)
FileClose($hOut)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Did you try anything like what Authenticity suggested?

$File = "CD\File\Path"
$nFile = "Hard\drive\path"
$hIn = FileOpen($File, 16)
$hOut = FileOpen($nFile, 18)
FileWrite($hOut, FileRead($hIn))
FileClose($hIn)
FileClose($hOut)
...haven't had a chance yet. I only needed a dozen or so files and FileCopy/FileSetAttrib was good enough for now. At some point I may need to move many files in many folders from a CD to a Hard Drive, and will probably look in to it further then. Unfortunately, I have little time to prepare right now. BTW, I couldn't figure out how to set attributes on a folder. Is there a function for that or would you just call cacls or xcalcs in a RunWait and be done with it?

Share this post


Link to post
Share on other sites

According to the helpfile for FileSetAttrib:

You get it? :)

Maybe I'm missing something obvious. I made a new folder in my script folder and ran: FileSetAttrib(@scriptdir & "\New Folder","-R",1) and didn't see any change to the Read Only checkbox of the folder's properties. It's a box-in-a-box...not a check, not empty. The 1 indeed changes all the files in the folder. I thought "-R" would clear the Read Only box on the folder and "+R" would check the box.

Share this post


Link to post
Share on other sites

Maybe I'm missing something obvious. I made a new folder in my script folder and ran: FileSetAttrib(@scriptdir & "\New Folder","-R",1) and didn't see any change to the Read Only checkbox of the folder's properties. It's a box-in-a-box...not a check, not empty. The 1 indeed changes all the files in the folder. I thought "-R" would clear the Read Only box on the folder and "+R" would check the box.

The "box-in-a-box" is there no matter if it's "Read Only" or not. Try changing the properties manually by rightklicking the file, exit the dialog and then check the properties again and you will se the "box in a box".... Always the box... Just test it with FileGetAttrib() if you don't trust Explorer.

Share this post


Link to post
Share on other sites

The "box-in-a-box" is there no matter if it's "Read Only" or not. Try changing the properties manually by rightklicking the file, exit the dialog and then check the properties again and you will se the "box in a box".... Always the box... Just test it with FileGetAttrib() if you don't trust Explorer.

You're right. Thanks for pointing that out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0