LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rename a file with invalid characters

Hello,

 

I have an application which writes some details to a location in server. The filenames contain the timestamp with abbreviated month (e.g. Jul, Aug). One of the computers is in Chinese & the filename it created is in Chinese. But my server is in English and the LabVIEW in that is not able to access this file. I tried renaming from LabVIEW using the Advanced File Palette and also using the kernel32.dll. Both did not work. Can you help me to rename these files to some valid string? There is a huge list of files.

 

Thanks,

Priyadarsini S 

0 Kudos
Message 1 of 4
(2,689 Views)

Can you rename using the command line "rename"?  I assume if the kernel32 method didn't work this wouldn't either but if it does you can rename using the commanline system exec call in LabVIEW.

 

You may also have difficulties with unicode strings in LabVIEW.

 

https://decibel.ni.com/content/docs/DOC-10153

0 Kudos
Message 2 of 4
(2,682 Views)

Hi Hooovahh,

 

As expected the system exec also did not work. But I found a workaround. If I choose the file containing invalid characters in its name & try to rename it does not work. But when I used the wildcard it worked. E.g. rename "*.txt" "1.txt". Yet another issue I faced is this will rename only one of the txt files to 1.txt. I did some extensive browsing to rename multiple files with some numeric series, seems like there is no simple solution that runs from the command prompt. So for now, I rename 1 file, read its contents and delete it and rename the next file. I will really appreciate if somebody could point me to a way to rename multiple files.

 

Thanks,

Priyadarsini S

0 Kudos
Message 3 of 4
(2,640 Views)

Hi priya,

 

this will rename only one of the txt files to 1.txt

Well, it doesn't make sense to rename more than one file to the very same filename…

 

The filenames contain the timestamp with abbreviated month (e.g. Jul, Aug). One of the computers is in Chinese & the filename it created is in Chinese.

That's why I prefer just numbers for timestamps in filenames. Using a format like "%y%m%d-%H%M" is readable by humans and fits nicely in Windows standard sorting algorithms…

 

a way to rename multiple files

Call rename several times, but provide a different target name each time… Even the Windows shell allows simple FOR loops!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(2,632 Views)