LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search folders and rename the file

Solved!
Go to solution

In my C:\, I have a number of folders, namely C:\myfolder1, C:\myfolder2, C:\myfolder3.. and in each folder, I have several text file *.txt.

I want to have a code which scan through all the C:\myfolder* , and rename the text file to bin file, eg. abc.txt to abc.bin.

I know I can do this easily using command prompt. But how can I do this in LV?

Main thing is how to go through all myfolder*?

0 Kudos
Message 1 of 12
(2,375 Views)

To get you started, look in the Advanced File Fuctions pallete for "ListFolder.vi".  It can give you a list of subfolders and/or files in a folder.  There is also the "Recursive File List.vi" which will even search inside the subfolders.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 12
(2,369 Views)
Solution
Accepted by topic author splee

Upto my knowledge there is no direct function for Renaming but you can do by moving the file and pasting with the target file. See the attached example.

-----

The best solution is the one you find it by yourself
Message 3 of 12
(2,360 Views)

a small mod to P's code.   Copy file and delete file to an effective job of renaming and you probably want to keep the name and just replace the extension to avoid that bad file name error popping up all the time Smiley Surprised

BH.png


"Should be" isn't "Is" -Jay
Message 4 of 12
(2,356 Views)

Ha.. This things I have never tried with that question only I tried doing it. Thanks Jeff.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 12
(2,353 Views)

Hi P Anand,

Your VI does not work.

Is it supposed to search in C:\, find all the *.txt file and rename them to *.bin? Can't seem to get it to work. Or did I miss anything?

0 Kudos
Message 6 of 12
(2,323 Views)

Hi Jeff,

Your VI doesn't seem to work either...

0 Kudos
Message 7 of 12
(2,320 Views)

Both the code will work but don't give the C: or 😧 as a path because it searches deep into all the directory thats why it seems not working go to a particular folder and try renaming a .txt file it will work.

-----

The best solution is the one you find it by yourself
Message 8 of 12
(2,316 Views)

Oh yes both works 😛

but why is that Jeff solution, it rename file1.txt to file1file1.bin?

0 Kudos
Message 9 of 12
(2,311 Views)

I'd do a System exec "rename *.txt *.bin" 🙂

 

/Y 

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 12
(2,305 Views)