首页 > 其他分享 >函数:file.move 移动文件

函数:file.move 移动文件

时间:2024-07-22 13:08:13浏览次数:7  
标签:文件 函数 -- move file path 移动 tpath

原文链接: https://luabox-book.touchsprite.com/dev_docs/8/7.html

函数名称:移动文件

函数功能:移动文件到新的目录下

函数方法

flag = file.move(path,tpath)

参数类型必填说明
path string 待移动文件的路径,
相对路径(仅支持 v1.0.6 及其以上版本)如 "ceshi.png" 表示当前流程文件夹下的 ceshi.png 文件
tpath string 要移动到的文件路径,注意先判断是否有重名文件或文件夹,
相对路径(仅支持 v1.0.6 及其以上版本)
返回值类型说明
flag boolean true - 移动成功,false - 移动失败

 

函数用例:

--相对路径,仅支持 v1.0.6 及其以上版本
--相对路径为当前流程文件夹:/sdcard/LuaBox/Projects/流程名称/
--待移动文件的路径,表示当前流程文件夹下的 222.log 文件
path = "222.log"
--要移动到的文件夹,表示当前流程文件夹下的测试文件夹
tpath = "测试/"
--判断文件是否存在
flag1 = file.isExist(path)
flag2 = file.isExist(tpath)
if  flag1 and flag2 then
      flag3=file.move(path,tpath.."error.log")
    if  flag3 then
        dialog("移动成功",5000)
    else
        dialog("移动失败",5000)
    end
else
    dialog("文件(夹)不存在",5000)
end

  

--待移动文件的路径
path = "111.lua"
--要移动到的文件夹
tpath = "测试/"
--判断文件是否存在
flag1 = file.isExist(path)
flag2 = file.isExist(tpath)
if  flag1 and flag2 then
      flag3=file.move(path,tpath.."222.lua")
    if  flag3 then
        dialog("移动成功",5000)
    else
        dialog("移动失败",5000)
    end
else
    dialog("文件(夹)不存在",5000)
end

  

注意事项

  • 待移动和要移动到的文件路径必须带文件名,文件名和扩展名可修改。

标签:文件,函数,--,move,file,path,移动,tpath
From: https://www.cnblogs.com/Dongmy/p/18315812

相关文章

  • [1038] Move the Adobe Acrobat to the left screen if it is in the right screen
    Inpython,itisdifficulttocaptureit.Butwecanuseanotherwaytodothis.Eachtime,whenweopentheAdobeAcrobat,itwillshowsomethinglikethis:Ifitisintheleftscreen,thebluearrowshouldbeinthespecificarea.Sowecanuse pyauto......
  • 有没有办法让用户输入 url 查询并使用单个函数过滤数据库?
    我正在使用DjangoRest框架和PostgreSQL,构建一个返回本NBA赛季所有统计数据的API。不是有一个函数来返回每个类别的统计信息,例如:@api_view(['GET'])defsortByRebounds(request):"""Returnsallstatsinthedatabasesortedbyreboundspergame"""strin......
  • 如何在 vercel 部署中路由 python 和 typescript 无服务器函数
    我从一个带有Next.js和Typescript前端以及python后端的全栈应用程序开始。由于我们想在vercel上部署,因此我们将所有后端功能迁移到/api文件夹中的typescript函数中,可通过以下方式访问:fetch('api/**foldername**)问题是我有一个简单的pytorch模型,因此......
  • office365.sharepoint 中的 moveto 或 move_to_using_path 是否处于活动状态?
    我正在尝试使用Office365-REST-Python-Client中的示例将文件从一个文件夹移动到另一个文件夹,但它不起作用:fromoffice365.sharepoint.client_contextimportClientContextfromoffice365.sharepoint.files.move_operationsimportMoveOperationsfromtestsimporttest_t......
  • 莫比乌斯函数与莫比乌斯反演
    9.莫比乌斯函数与莫比乌斯反演9.1莫比乌斯函数9.1.1定义设\(\mu\)为莫比乌斯函数,则有:\[\mu(x)=\begin{cases}1\qquad(n=1)\\0\qquad(∃\i\(ki=x,k\inZ\rightarrow\sqrt{i}\inZ))\\(-1)^{\sum_{i\inprime}[i\midx]}\end{cases}\]直观地说,只要\(x\)的某个质......
  • 常用损失函数 LossFunction
    文章结构损失函数在神经网络中的位置常用的损失函数(结构:解释,公式,缺点,适用于,pytorch函数)MAE/L1LossMSE/L2LossHuberLoss对信息量、熵的解释relativeentropy相对熵/Kullback-LeiblerKLLoss CrossEntropyLoss交叉熵(包含对softmax层的解释)相对熵、熵、和交叉......
  • pyvirtualdisplay: FileNotFoundError: [WinError 2] 系统找不到指定的
    我正在学习AndrewNg的课程,即2022机器学习专业。课程3的第三周有一个实验室,其中代码如下:frompyvirtualdisplayimportDisplayDisplay(visible=0,size=(840,480)).start();但是当我在jupyter中运行单元格时,出现以下错误:FileNotFoundError......
  • Python学习计划——2.3常用内置函数(len, max, min, sum, etc.)
    Python提供了许多内置函数,用于简化对数据结构的操作。以下是一些常用的内置函数及其详细说明。1.len()len()函数用于返回对象(如列表、元组、字符串、字典等)的长度(元素个数)。示例:#列表fruits=["apple","banana","cherry"]print(len(fruits))#输出:3#元组c......
  • 如何使用Python计算位移自相关函数?
    我正在使用python来分析粒子的异常扩散。我已经得到了粒子轨迹的位移,我想计算并绘制位移自相关与滞后时间t的关系。我认为可能存在使用t和位移(如deltar)的自相关函数的一般函数,但我不能没找到。我可以得到函数或代码吗?可以使用numpy和matplotlib库在Python......
  • 【数学】【模板】欧拉函数
    欧拉函数思想\(\varphi(n)\)表示的是\(1\simn\)中与\(n\)互质的个数。怎么求\(\varphi(n)\)呢?先将\(n\)质因数分解:\(n=p_1^{a_1}p_2^{a_2}\cdotsp_k^{a_k}\),那么\(\varphi(n)=n\left(1-\dfrac{1}{p_1}\right)\left(1-\dfrac{1}{p_2}\right)\cdots\left......