CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Renaming files in loop using scheme (https://www.cfd-online.com/Forums/fluent-udf/228101-renaming-files-loop-using-scheme.html)

manish1308 June 19, 2020 14:01

Renaming files in loop using scheme
 
Hi I am trying to use scheme to rename my files.
I found the command (rename-file "first_file.csv" "second_file.csv"). This helps me to rename a single file.
I want to use it in a loop to rename multiple files. How can I do that?
I tried using something like this-
(do ((x 2 (+ x 1))) ((> x3))
(rename-file ("Wallprof_Csv_~a.c" "output_~a.c" x x )))

But this does not work.
Can you guys help me out with this.
Thank you.

vinerm June 19, 2020 15:23

Renaming Files
 
Why do you want to use Fluent to rename files? Use bash (or batch or powershell, if using Windows) to do that. Though it can be done yet Fluent is not meant for renaming files.

manish1308 June 19, 2020 16:24

Hi,
I am running a do loop which has scheme commands to run the entire simulation. So I need to use the rename command in this do loop. Can you please let me know how can I use rename file in a do command. If I can get that done I am able to solve the whole issue.
Can you please let me know how it is done in Fluent. It would be a great help.

Thanks,
Manish

vinerm June 19, 2020 16:32

Format
 
The command does work the way you are using. However, if you want to replace ~a with some variable, you need to use format command.

manish1308 June 19, 2020 16:45

Hi.
I am trying to use this command. But it is giving me an error.
I also tried putting the whole thing in a bracket.

(do ((x 2 (+ x 1))) ((> x 3))
(rename-file (format #f "test_~a.csv" "output_~a.csv" x x )))

vinerm June 20, 2020 12:04

format
 
rename-file expects two arguments. So, you need to use format twice, working on each file separately.

manish1308 June 21, 2020 22:33

format
 
Hi,
Sorry I didnt get you. So does that mean I cannot use rename in a loop?

manish1308 June 21, 2020 22:47

format
 
Hello Sir,
I got what you were trying to imply. I was able use rename in the loop.
Thank you so much from your help.

Thank you,
Manish


All times are GMT -4. The time now is 03:18.