GetNewestFile> locks directory?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

GetNewestFile> locks directory?

Post by migro » Mon Sep 03, 2012 1:08 am

Hi,

after using "GetNewestFile>" the directory where the file is in, seems to be locked until Macro Scheduler is closed. Occurred under Windows XPsp3.

Can anyone confirm this, and if yes whats the solution to get the directory unlocked again?
regards
migro

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Sep 03, 2012 5:11 am

Define locked. I used GetNewestFile> on a folder at the root of C:\ and then opened Windows explorer and deleted the file that was found to be the newest. Using WinXP SP3.

What can I do to try to replicate?

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Mon Sep 03, 2012 10:36 am

Hi,

try to rename the directory where the file is located, while MS / the script is still open (MDL>pause ;-)
regards
migro

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Sep 03, 2012 3:08 pm

Ok, That was reproducable. The folder could not be renamed until I exited out of Macro Scheduler. Tried on my Win 7 machine and the function does NOT lock the folder as it does with Win XP.

No idea how to remedy this. We'll have to wait to hear what Marcus can do. In the mean time there is always DOS.

Code: Select all

Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run>cmd /c dir c:\folder\*.* /b /a-d /o-d > %temp_dir%dirlist.txt
ReadLn>%temp_dir%dirlist.txt,1,NewestFile
DeleteFile>%temp_dir%dirlist.txt

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Thu Sep 06, 2012 2:49 am

Thanks for Your help and the suggestion.

I have used the function primarily to get an idea when the folder, where the files are in, was created, because i missed a function to get a folders creation date.

I've done it inbetween with a little piece of VB-Code. Maybe it is usefull for someone who have the same needs.

Code: Select all

Let>strFolder=C:\temp
Gosub>GetDirDate
MDL>%strDirDate%

SRT>GetDirDate
   VBSTART
   Function GetFolderDate(strFolder)
      Set FSO = CreateObject("Scripting.FileSystemObject")
      Set Folder = FSO.GetFolder(strFolder)
      GetFolderDate= Folder.DateCreated
   End Function
   VBEND
   VBEval>GetFolderDate("%strFolder%"),strDirDate
   MidStr>%strDirDate%,1,10,strDirDate
END>GetDirDate
regards
migro

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts