当前位置:首页 » 文件管理 » bat当前时间文件夹

bat当前时间文件夹

发布时间: 2025-02-12 10:18:24

㈠ Windows和Linux下生成以当前时间命名的文件

生成以当前时间命名的文件对于当今两大主流系统都十分有用,在 Windows、Linux 操作系统,分别利用BAT批处理文件和Shell脚本,生成类似“20110228_082905.txt”以“年月日_时分秒”命名的文件。
Windows BAT批处理文件:
@echo off
set time_hh=%time:~0,2%
if /i %time_hh% LSS 10 (set time_hh=0%time:~1,1%)
set filename=%date:~,4%%date:~5,2%%date:~8,2%_%time_hh%%time:~3,2%%time:~6,2%
echo test %filename%.txt
Linux Shell 脚本:
#!/bin/sh
echo test $(date -d "today" +"%Y%m%d_%H%M%S").txt

㈡ bat创建以当前日期命名的文件夹

1、在当前文件夹内,右击新建》文本文档。

㈢ 如何批量修改文件名(bat),将一个文件夹下的所有文件加上当前时间

既然加序号,时间就仅取年月日:
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%i in ('dir/b *.bak^|findstr/v "20[0-9][0-9][0-1][0-9][0-3][0-9]"')do (
echo %%i
set "fn=%%i"
set "t=%%~ti"
set "t=!t:~,10!"
set "nt=%%~ni_!t:-=!"
set n=100&call :yky)
pause&goto :eof
:yky
set/a n+=1
if exist "%nt%_%n:~1%.bak" goto :yky
ren "%fn%" "%nt%_%n:~1%.bak"
goto :eof

热点内容
存储器答案 发布:2025-07-03 17:32:28 浏览:795
搭建服务器和分区 发布:2025-07-03 17:27:20 浏览:775
废品机械师如何升级电脑配置 发布:2025-07-03 17:27:11 浏览:24
国产手机存储 发布:2025-07-03 17:26:09 浏览:734
怎么在电脑上更改微信存储位置 发布:2025-07-03 17:18:18 浏览:863
phpmysql连接超时 发布:2025-07-03 17:05:09 浏览:796
服务器怎么设置电脑远程端口 发布:2025-07-03 16:28:46 浏览:72
电信无线路由器官方密码是什么 发布:2025-07-03 16:25:00 浏览:773
空间只能申请访问 发布:2025-07-03 16:23:27 浏览:735
华硕天选2air配置如何选择 发布:2025-07-03 16:10:09 浏览:571