Moving files with the rename command

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

Moving files with the rename command

Post by PoLyGLoT » Sun Feb 19, 2017 8:32 pm

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.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Moving files with the rename command

Post by [-hh] » Mon Feb 20, 2017 12:02 am

Was crossing another answer.
Last edited by [-hh] on Mon Feb 20, 2017 12:07 am, edited 1 time in total.
shiftLock happens

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Moving files with the rename command

Post by jmburnod » Mon Feb 20, 2017 12:04 am

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
https://alternatic.ch

PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

Re: Moving files with the rename command

Post by PoLyGLoT » Mon Feb 20, 2017 1:28 am

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!

Post Reply