Page 1 of 1

Copying files

Posted: Fri Mar 05, 2021 3:24 am
by DavJans
I'm having an issue with RevCopyFile, Im not quite sure what im doing wrong but I bet its something stupid

This Works:

Code: Select all

--copy nc1 files
repeat for each line tLine in tPartList
	put ".nc1" after tLine
	revCopyFile "\\10.0.15.15\NC Files\" & tLine, "C:\NC Files\"
end repeat
This does not:

Code: Select all

--copy nc1 files
set the defaultfolder to "\\10.0.15.15\NC Files\"
repeat for each line tLine in tPartList
	put ".nc1" after tLine
	revCopyFile tLine, "C:\NC Files\"
end repeat

Re: Copying files

Posted: Fri Mar 05, 2021 5:40 am
by liveme

Code: Select all

revCopyFile defaultfolder&tLine, "C:....
:roll:
mayyyyybe :?:

Re: Copying files

Posted: Fri Mar 05, 2021 12:17 pm
by bogs
I wouldn't say stupid, especially considering some of the lulus I've pulled heh, but there are a few things I'd say about your code (even the one that *works*).

1. I am making an assumption here that you are on (some version) of windows. IF that is the case, know that paths generally follow the forward slash unix style "/", rather than the backwards slash windows only style "\"

2. liveme is correct, you need the folder, but you don't need the 'C:' part (unless you are specifically designating 1 disk from multiple drives)

3. Below is an example of how I would have done it (the fields are just for visual representation and could be any variable you wanted really)

Code: Select all

on openCard
 # I did not have an already pre-determined folder, 
 -- you do, so the answer part would mean nothing for you...
   answer folder "Choose a folder..."
   if it is not empty then set the defaultFolder to it
   put the files into field 1 # could be any variable...
   
   # This is just the destination folder I made up, again, it is only for demonstration purposes...
   put (specialFolderPath("Desktop") & "/CopiedFiles") into tmpFolder 
   
   # Here is the meat of the difference....
   repeat for each line x in field 1
   # your looking for a specific extension, .ncl. In this case, I am testing to see if the file contains ".txt"
   -- if it does, then copy it from folder to folder
      if x contains ".txt" then revCopyFile(x),tmpFolder
   end repeat
   
   # This part is unnescessary, again just for visual representation...
   set the defaultFolder to tmpFolder
   put the files into field 2
end openCard
And here is the visual representation of the above -

Image

Hope that was of some help.