Page 1 of 1

Moving files with the rename command

Posted: Sun Feb 19, 2017 8:32 pm
by PoLyGLoT
Hi all,

I have a field that displays a list of files in a folder. I then open each file, check how many lines each file has, and put that information directly next to the file name in the field (e.g., "File 1, 123"). I am then using a repeat loop to examine each file, and if it does not have a certain number of lines, I want to move that file to a new folder.

Code: Select all

myFile = "C:/Users/PC/Desktop/REHalldata/Output_Session1_A10LVHTF26QHQC_a7ess6el98.csv"
goodFolder = "C:/Users/PC/Desktop/REHalldata/Good"
So "Good" is a folder inside the "REHalldata" folder. I simply want to move it from REHalldata into the Good folder.
I've tried it a bunch of ways and it never works!

Code: Select all

rename URL("file:" & myFile) to specialFolderPath(goodFolder)
rename URL("file:" & myFile) to specialFolderPath(tFolder & "/" & "Good")
rename file myFile to specialFolderPath(tFolder & "/" & "Good")
rename file myFile to specialFolderPath("\Good")
rename file myFile to specialFolderPath("Good")
Any help is appreciated.

Re: Moving files with the rename command

Posted: Mon Feb 20, 2017 12:02 am
by [-hh]
Was crossing another answer.

Re: Moving files with the rename command

Posted: Mon Feb 20, 2017 12:04 am
by jmburnod
Hi,

specialFolderPath need param like "documents"

In your case you can try this, it should work

Code: Select all

put "Output_Session1_A10LVHTF26QHQC_a7ess6el98" into tNameFile
put ""C:/Users/PC/Desktop/REHalldata" into tFolderS
put "C:/Users/PC/Desktop/REHalldata/Good" into tFolderD
put tFolderS & "/" & tNameFile into tPathS
put tFolderD & "/" & tNameFile into tPathD
rename file tPathS to tPathD
Best regards
Jean-Marc

Re: Moving files with the rename command

Posted: Mon Feb 20, 2017 1:28 am
by PoLyGLoT
jmburnod wrote:Hi,

specialFolderPath need param like "documents"

In your case you can try this, it should work

Code: Select all

put "Output_Session1_A10LVHTF26QHQC_a7ess6el98" into tNameFile
put ""C:/Users/PC/Desktop/REHalldata" into tFolderS
put "C:/Users/PC/Desktop/REHalldata/Good" into tFolderD
put tFolderS & "/" & tNameFile into tPathS
put tFolderD & "/" & tNameFile into tPathD
rename file tPathS to tPathD
Best regards
Jean-Marc
Thank you very much. That resolved the issue. Much appreciated!