Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Description File (Apparently) Getting Locked

Jun
762
16
I have a script whose intention is to copy file descriptions from the files in one directory to the same file in another directory. When I run it (for example, below I ran copydesc c*.btm dropbat:), I get occasional errors like the following:

Code:
Updating description of cdtests.btm
TCC: (Sys) C:\commands\bat\copydesc.btm [87]  The process cannot access the file because it is being used by another process.
 "DESCRIPT.ION"

That line in the code (87) is:

Code:
describe %destfile /d"%desc"

Many of the descriptions update without generating an error message. As it is, I included a DELAY 1 in the loop in case I was accessing the DESCRIPT.ION file too fast, but one second between accesses should be more than enough delay. If I repeat the very same command, I get errors on different files, so it is not something about the particular file or its description.

Does anyone have an idea about what could be going wrong (what I might be doing wrong)?
 
I don't think that you do something wrong.

Did you check which process is locking the DESCRIPT.ION files - perhaps it's not even the describe command (there are many possibilities to doing that - for example Sysinternals "handle") ...? So it could be a realtime antivirus program or something like that ...
 
No, I did not check what process is locking the description file. It is happening at random and temporarily. After an error message for one file, the script continues copying descriptions for other files. Then another error message appears.

I don't know what program would lock the file at random times, so it would seem most likely to be related to my copying the descriptions.
 
Yes, related - but that means not that it comes REALLY from the describe command. In such tasks other processes can be involved too.

I would check it, then you would be a step further. Sysinternals command "handle" should be easy to find/download then a "handle filename" should be enough.

PS: Here the link:
 
When you copy a file (including descript.ion) TCC will look in the descript.ion file for the source filename and if found, copy it to the target descript.ion. So (depending on how you are doing this) you're probably hitting descript.ion multiple times for a single copy.

If you're using the COPY command, use the /Nn option to avoid the multiple reads/writes.
 
I'm not using the COPY command. The files had been copied previously to the target folder. Subsequently, I added descriptions to the files in the source directory. The purpose of the script is to transfer those new descriptions to the copies in the other folder.

I am doing this by using @DESCRIPT to get the description of the file in the source folder and then using the DESCRIBE command to save the description to the file of the same name in the target folder. I'm not copying any files; I'm just reading and writing descriptions.

As a workaround, I could just force a new copy of the source file to the destination. The risk with that is that the file in the target folder might be newer than the source file and would be overwritten by the older file. Copying just the description does not carry that risk.
 
I have been trying to make clear that I do not want to copy the files; I want to copy only the descriptions. In thinking about how to explain this again, I finally solved the problem.

The reason I don't want to copy the files themselves is that in some cases they are deliberately different. One BTM file is for use on my desktop computer, while the other, with the same name, is for use on my laptop. Now that I have been working hard to add descriptions to the files on my desktop, I wanted to copy the descriptions to the files of the same name in the directory with the files for my laptop.

And there's where the problem arose. I'm sharing the files via the Dropbox folder that is shared between the two computers. And there, of course, is where the competing access to the files is arising. Dropbox is constantly syncing the files to and from the cloud.

So now I just moved all the files from the directory in the Dropbox area to a memory stick. Then I used my copydesc.btm script to copy the descriptions. I still left a little delay (100 ms) between description copies, which made it easy to watch the progress on the screen. NO ERRORS. All the descriptions were copied without a hiccup. Then I moved all the files off the memory stick back to the Dropbox folder.

I have gotten so used to working with Dropbox as if the folders were on my local drive that I forgot about how the synchronization actually takes place. There's another process running out of sight that takes care of that. The example of my command in my initial message hinted at all this: copydesc c*.btm dropbat:. The directory alias "dropbat:" is the Dropbox folder with copies of the batch scripts from my "bat:" folder on the local disk.

@Alpengreis, your suggestion probably would have elucidated this problem if I hadn't finally figured it out in my own brain. I did download the "handle" tool and had started to play with it, but I had some real work to do. (I had all the SysInternal tools here, but was shocked to see that they were decades old. Time to fetch new copies.)

P. S. Rex, why are all the tools disabled in the forum? I can't add bold or italics or mark text as inline code. Everything is grayed out.
 
It was the "Toggle BB Code" button on the right. Apparently I had clicked it at some point.
 
Back
Top