I currently have a dataset of images with no folder structure. However, based on the existing image name, I want to rename and move the file to a different folder structure (assuming the folders exist, I can also just make the folder programmatically).
In Python, I can just rename the file and it will move to the updated location I specify. How can I rename a file in Julia?
In Julia's base filesystem, there is an mv command which you can use to move and rename the file as follows:
julia> write("hello.txt", "world"); # here we create a text file.
julia> mv("hello.txt", "goodbye.txt") # we then move it, but the file stays in the same dir so it is just renamed from hello to goodbye.
"goodbye.txt"
julia> mv("goodbye.txt", "./test/hello.txt") # in this example, we actually move the file from the existing folder into a new test folder as well as change the name.
"./test/hello.txt"
julia>
You can read more about the mv function in the Julia docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With