如何在Julia中重命名文件?



我目前有一个没有文件夹结构的图像数据集。但是,基于现有的图像名称,我想重命名文件并将其移动到不同的文件夹结构中(假设文件夹存在,我也可以通过编程方式创建文件夹)。

在Python中,我可以重命名文件,它将移动到我指定的更新位置。如何在Julia中重命名文件?

在Julia的基本文件系统中,有一个mv命令,您可以使用它来移动和重命名文件,如下所示:

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> 

您可以在Julia文档中阅读更多关于mv函数的信息。

最新更新