加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 如何在不遵循连接点的情况下删除Windows目录?

发布时间:2020-12-15 22:01:17 所属栏目:大数据 来源:网络整理
导读:我有一个Perl脚本,需要删除包含其所有内容的目录. 有时,此目录包含到另一个目录的联结点.如果我天真地使用rmtree(),rmtree()调用也将删除联结目标文件夹中的所有文件.我正在寻找一种不这样做的方法,而只是删除了交叉点. 非Perl解决方案也将受到赞赏. 解决方
我有一个Perl脚本,需要删除包含其所有内容的目录.
有时,此目录包含到另一个目录的联结点.如果我天真地使用rmtree(),rmtree()调用也将删除联结目标文件夹中的所有文件.我正在寻找一种不这样做的方法,而只是删除了交叉点.

非Perl解决方案也将受到赞赏.

解决方法

我只是在Google中键入了“联结点”并找到了我的方式
http://en.wikipedia.org/wiki/NTFS_junction_point

Command Prompt (cmd.exe)

  • The dir
    command in Windows 2000 or later
    recognizes junction points,displaying
    instead of in
    directory listings (use dir with the
    /A or /AL command-line switch).
  • Any
    commands that would normally affect
    files inside a normal directory will
    act the same here. Thus the command
    del myjunction should not be used —
    this will just delete all the files in
    the targeted directory.
  • The commands
    rmdir and move work fine with
    junctions,with the caveat that move
    won’t let the junction move to another
    volume (as opposed to Windows
    Explorer,as mentioned above.)
  • The
    rmdir command is safe in that it only
    deletes the junction point,not the
    targeted files. Whilst walking through
    the directory with the command line
    interface,files can be deleted,but
    unlike explorer,directories can also
    be deleted (using rmdir /s dirname for
    example.)
  • Using the linkd command with
    the /d switch is a safe way to delete
    junction points.

从我所看到的,你可以,例如,使用dir和grep输出< JUNCTION>或使用Windows rmdir.我认为您可以通过系统使用Perl中的任何一个.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读