Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
Phiasco
- Posts: 9
- Joined: Tue May 10, 2011 10:59 pm
Post
by Phiasco » Mon Mar 26, 2012 8:49 pm
Hello, I have files being dropped into a hot folder to be moved to an organized folder structure. Hundreds of files are being dropped here each day. In the past this was being done with Applescript on an Apple Server, but this past weekend the workflow was moved to a Windows 2k8 server. The below code works flawlessly until a file is dropped in that is 8 characters + . + extension. As an example, if I were to drop two files
PAB1231201.pdf
PAB12312.pdf
into the folder, the app will crash. If I drop the first file in alone, it will perform as expected. If I drop the second file in alone, the app will crash. I see nothing in the code that would cause such a difference. We use many combinations of characters in our job structure and in every case where a file uses the 8.3 naming, the error happens.
Thanks for any help
Robert Short
Code: Select all
on putAwayProofs
-- Establish a path where the new documents are stored and where they will be moved to.
--Live Paths
if the platform is "MacOS" then
put "/Volumes/ART/PDFs/PROOF" into fixedDropPathP
put "/Volumes/PROOFs/Proofs201" into fixedDestination
else if the platform is "Win32" then
put "E:/ART/PDFs/PROOF" into fixedDropPathP
put "E:/PROOFs/Proofs201" into fixedDestination
end if
put "/" into pathDelim
-- Get a list of the new files.
set the defaultFolder to fixedDropPathP
put the detailed files into tFileListP
--Establish base time value for modification test
put the date && the time into newTimeSeconds
convert newTimeSeconds to seconds
-- Process the file list
repeat with x = 1 to number of lines of tFileListP
// get modification date of file set elapsed time since modification
put item 5 of line x of tFileList into oldTimeSeconds
put newTimeSeconds - oldTimeSeconds into elapsedSeconds
if char 1 of item 1 of line x of tFileListP is among the items of "A,P,T" then
put "OK" into theProduct
else
put "ERROR" into theProduct
end if
if theProduct is not "ERROR" and elapsedSeconds > 90 then
//Build Folder Structure if it does not exist
put item 1 of line x of tFileListP into dealNumber
put fixedDestination & char 8 of dealNumber & pathDelim & char 1 to 3 of dealNumber into variableDestination
if there is not a folder variableDestination then create folder variableDestination
put variableDestination & pathDelim & char 1 to 8 of dealNumber into variableDestination
if there is not a folder variableDestination then create folder variableDestination
//Copy and rename the Proof PDF
set defaultFolder to variableDestination
put variableDestination & pathDelim & dealNumber into variableDestinationFile
if there is a file variableDestinationFile then delete file variableDestinationFile
revCopyFile fixedDropPathP & pathDelim & dealNumber, variableDestination
delete file fixedDropPathP & pathDelim & dealNumber
put CR & dealNumber & " - Proof Updated in Customer Proofs folder." before field "Data"
end if
end repeat
end putAwayProofs
-
mwieder
- VIP Livecode Opensource Backer

- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
-
Contact:
Post
by mwieder » Mon Mar 26, 2012 9:23 pm
Robert-
There's very little error checking in your code. I assume you meant to say tFileListP here...
Code: Select all
put item 5 of line x of tFileList into oldTimeSeconds
and you might try checking "the result" after your file system calls to see if they're successful
Code: Select all
put newTimeSeconds - oldTimeSeconds into elapsedSeconds
if elapsedSeconds is a number and elapsedSeconds > 0 then
if there is not a folder variableDestination then create folder variableDestination
if the result is not empty then ...
if there is not a folder variableDestination then ...
put variableDestination & pathDelim & char 1 to 8 of dealNumber into variableDestination
if there is not a folder variableDestination then create folder variableDestination
if the result is not empty then ...
if there is not a folder variableDestination then ...
-
Phiasco
- Posts: 9
- Joined: Tue May 10, 2011 10:59 pm
Post
by Phiasco » Tue Mar 27, 2012 5:14 am
Yes, very true. The transfer from the Mac server to the Windows server was unplanned and implemented quickly which is why there is no error capture. Just make it work was the task handed to me. Luckily, we have a rather strict workflow in place which prevents many common errors. The tFileListP was a huge catch which made the application stable for the remainder of the day once implemented. That 90 second delay before processing a file is critical. If the pdf is being written while the app is processing it, it either corrupts the pdf or as we see here, crashes the app. The 8.3 formatted files in our environment tend to be much larger than the longer named files.
Thank you very much for your help. And I will be adding in the error capture next week once we complete the decommission of the Mac server. This was only one of many tasks that had to be converted from Apple Script to Windows friendly.
-
mwieder
- VIP Livecode Opensource Backer

- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
-
Contact:
Post
by mwieder » Tue Mar 27, 2012 5:39 pm
There is an unfortunate (or at least used to be) difference in the way file transfers are handled in Windows and Macintosh operating systems. On mac systems the file size is known at the start of the file transfer, and the file is not made available to the file system until the copy is complete. Windows systems take take a more dumb^H^H^H^Hbasic approach to things and just keep copying until the end of the file - the end file size isn't known until the copy is finished.
BTW - using the copy command is much faster than LC's built-in revCopyFile. The following code snippet is thanks to Geoff Canyon on the use-list:
Code: Select all
on shellCopyFile tSource,tTarget
get shell("cp" && quote & tSource & quote && quote & tTarget & quote)
if it is not empty then
-- handle errors here*
end if
end shellCopyFile