首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >用于将目录复制到拇指驱动器的批处理脚本,按日期查找目录并在不存在时创建目录

用于将目录复制到拇指驱动器的批处理脚本,按日期查找目录并在不存在时创建目录
EN

Stack Overflow用户
提问于 2013-11-18 02:28:06
回答 1查看 109关注 0票数 0

我需要将"C:\PWE\FaxesOutgoing“目录复制到"E:\”(拇指驱动器)

我需要脚本来查看E:\是否有当前日期的现有目录(即: E:\MMDDYY)。如果是,请将C:\PWE\FaxesOutgoing中的任何文件复制到该目录(如果尚未存在)。

如果当前日期的目录不存在,则需要创建一个目录,然后将文件复制到该目录中。

我将把这个批处理文件设置为在每30分钟运行一次的调度程序中运行。

EN

回答 1

Stack Overflow用户

发布于 2013-11-18 03:35:38

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
set drive=e:\
set year=%date:~10,4%
set month=%date:~4,2%
set day=%date:~7,2%

if not exist "%drive%%month%%day%%year%" MD "%drive%%month%%day%%year%"

xcopy c:\pwe\faxesoutgoing "%drive%%month%%day%%year%"

未经过测试,但应该很接近。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20039080

复制
相关文章
python创建日期名的目录
backdir = "/data/backup/mysqlbackup/" mysqlbkdir = backdir + time +"/" if not os.path.exists(mysqlbkdir):     os.makedirs(mysqlbkdir) else:     pass
py3study
2020/01/08
1.2K0
Python脚本按照当前日期创建多级目录
使用python脚本按照年月日生成多级目录,创建的目录可以将系统生成的日志文件放入其中,方便查阅,代码如下:
我是李超人
2020/08/20
9980
自动清除日期目录shell脚本
    很多时候备份通常会使用到基于日期来创建文件夹,对于这些日期文件夹下面又有很多子文件夹,对于这些日期文件整个移除,通过find结合rm或者delete显得有些力不从心。本文提供一个简单的小脚本,可以嵌入到其他脚本,也可直接调用,如下文供大家参考。
Leshami
2018/08/13
6240
php案例:创建日期时间目录
贵哥的编程之路
2023/10/16
1850
php案例:创建日期时间目录
Python 按当前日期(年、月、日)创建多级目录的方法
先看实际效果,现在时间2018.4.26 使用python脚本按照年月日生成多级目录,创建的目录可以将系统生成的日志文件放入其中,方便查阅,代码如下: #!/usr/bin/env python #c
用户1214487
2018/05/28
1.9K0
linux 查找目录下的执行可脚本
find -L . -name \*.sh -o -name \*.py -o -name \*.pl ./misc/smaps.pl ./misc/switch_inet.sh ./misc/ini_parse.pl ./misc/parse_agent_value.pl ./misc/show_process_of_USER.pl ./pkgtools/mkpkg.sh -o =or -a =and -L 追踪所有符号链接 find命令的一般格式为: find [-H] [-L] [-P]
葫芦
2019/04/17
2.3K0
python 查找目录中最大的python文件 脚本
""" Find the largest Python source file in an entire directory tree. Search the Python source lib, use pprint to display results nicely. """ import sys, os, pprint trace = False if sys.platform.startswith('win'): dirname = r'C:\Python31\Lib'
用户5760343
2022/05/13
9130
/目录 、/home目录 、~目录的区别
cd / : 从任何用户执行该命令都会进入同一个目录,即所有用户共享,其下文件如图
狼啸风云
2019/10/22
4.1K0
/目录 、/home目录 、~目录的区别
fat文件系统查找、删除、创建目录
查找一个文件是通过文件名查找的,对于fat文件系统,可以直接从vfat_lookup函数看
哆哆jarvis
2022/11/21
1.8K0
MarkDown 创建目录
创建类似于书本目录层级 通过 "-"来实现 \tab - \tab \tab - \tab \tab \tab - 如此便可以实现上图的效果
onety码生
2018/11/21
1.7K0
python进入文件目录 命令_python创建目录
Python可以使用os.chdir()方法转到指定目录。os.chdir() 方法用于改变当前工作目录到指定的路径。
全栈程序员站长
2022/09/27
3.7K0
python 目录复制 脚本
""" ################################################################################ Usage: "python cpall.py dirFrom dirTo". Recursive copy of a directory tree. Works like a "cp -r dirFrom/* dirTo" Unix command, and assumes that dirFrom and dirTo are both directories. Was written to get around fatal error messages under Windows drag-and-drop copies (the first bad file ends the entire copy operation immediately), but also allows for coding more customized copy operations in Python. ################################################################################ """
用户5760343
2022/05/13
7530
python备份目录脚本
#!/usr/bin/env python #backup app python script. import os import time import sys
py3study
2020/01/10
8280
Linux 查看目录下所有的日期信息(按最新日期排序)
1、查看当前目录文件 2、查看目录下文件日期的详细信息 ls --full-time 3、编写 shell 脚本 :monitor.sh #!/bin/bash echo "-------------
静谧星空TEL
2021/04/27
3.5K0
Linux 查看目录下所有的日期信息(按最新日期排序)
python 查找指定目录下的指定类型文件 脚本
""" Find the largest file of a given type in an arbitrary directory tree. Avoid repeat paths, catch errors, add tracing and line count size. Also uses sets, file iterators and generator to avoid loading entire file, and attempts to work around undecodable dir/file name prints. """
用户5760343
2022/05/13
1.6K0
python 查找多个目录下的最大Python文件 脚本
""" Find the largest Python source file on the module import search path. Skip already-visited directories, normalize path and case so they will match properly, and include line counts in pprinted result. It's not enough to use os.environ['PYTHONPATH']: this is a subset of sys.path. """
用户5760343
2022/05/13
1.1K0
Python 文件复制&按目录树结构拷贝&批量删除目录及其子目录下的文件
#!/usr/bin/env/ python # -*- coding:utf-8 -*- __author__ = 'shouke' import os import subprocess # 复制文件或目录到指定目录(非自身目录) def copy_dir_or_file(src, dest): if not os.path.exists(dest): print('目标路径:%s 不存在' % dest) return [False, '目标路径:%s 不存在' % dest] elif not os.path.isdir(dest): print('目标路径:%s 不为目录' % dest) return [False, '目标路径:%s 不为目录' % dest] elif src.replace('/', '\\').rstrip('\\') == dest.replace('/', '\\').rstrip('\\'): print('源路径和目标路径相同,无需复制') return [True,'源路径和目标路径相同,不需要复制'] if not os.path.exists(src): print('源路径:%s 不存在' % src) return [False, '源路径:%s 不存在' % src] # /E 复制目录和子目录,包括空的 /Y 无需确认,自动覆盖已有文件 args = 'xcopy /YE ' + os.path.normpath(src) + ' ' + os.path.normpath(dest) # 注意:xcopy不支持 d:/xxx,只支持 d:\xxxx,所以要转换 try: with subprocess.Popen(args, shell=True, universal_newlines = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: output = proc.communicate() print('复制文件操作输出:%s' % str(output)) if not output[1]: print('复制目标文件|目录(%s) 到目标目录(%s)成功' % (src, dest)) return [True,'复制成功'] else: print('复制目标文件|目录(%s) 到目标目录(%s)失败:%s' % (src, dest, output[1])) return [False,'复制目标文件|目录(%s) 到目标目录(%s)失败:%s' % (src, dest, output[1])] except Exception as e: print('复制目标文件|目录(%s) 到目标目录(%s)失败 %s' % (src, dest, e)) return [False, '复制目标文件|目录(%s) 到目标目录(%s)失败 %s' % (src, dest, e)] # 删除指定目录及其子目录下的所有子文件,不删除目录 def delete_file(dirpath): if not os.path.exists(dirpath): print('要删除的目标路径:%s 不存在' % dirpath) return [False, '要删除的目标路径:%s 不存在' % dirpath] elif not os.path.isdir(dirpath): print('要删除的目标路径:%s 不为目录' % dirpath) return [False, '要删除的目标路径:%s 不为目录' % dirpath] # 注意:同xcopy命令,del也不支持 d:/xxxx,Linux/Unix路径的写法,只支持d:\xxx windows路径的写法 args = 'del /F/S/Q ' + os.path.normpath(dirpath) # /F 强制删除只读文件。 /S 删除所有子目录中的指定的文件。 /Q 安静模式。删除前,不要求确认 try: with subprocess.Popen(args, shell=True, universal_newlines = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
授客
2019/09/11
1.9K0
【Linux 内核】Linux 内核源码目录说明 ② ( drivers 目录 | fs 目录 | include 目录 | init 目录 | ipc 目录 | kernel 目录 )
drivers 目录中存储了 驱动程序 相关代码 , 如 USB 总线驱动程序 , PCI 总线驱动程序 , 显卡驱动程序 , 网卡驱动程序 等 ;
韩曙亮
2023/03/30
12.4K0
【Linux 内核】Linux 内核源码目录说明 ② ( drivers 目录 | fs 目录 | include 目录 | init 目录 | ipc 目录 | kernel 目录 )
[linux] du查找数据大的目录
当磁盘满了的时候,想知道哪个目录下的数据最大 可以使用这个命令 du --max-depth=2 / 这样可以从/根目录开始找,找两级目录,总计出目录的大小 这样就可以找到了 du --max-de
唯一Chat
2021/08/06
8750
【目录】博客分类,方便查找
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
chenchenchen
2019/09/02
5820

相似问题

用于将目录复制到多个其他目录的Bash脚本

10

Bash脚本:将目录复制到外部驱动器-如何导航目录?

20

按日期将文件复制到目录中

14

创建批处理文件,将整个目录复制到新的变量目录

22

QFtp仅在目录不存在时创建目录

110
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文