标签:小代码
shell: ##################################### echo "time is" DATE=$(date +%Y%m%d) echo $DATE echo "creat a fileder named by time" mkdir -p $DATE read -p "input number:" num if [ $num -eq 10 ] then mv $DATE "pass" fi
#include <stdio.h>
#include<string.h>
#include <time.h>
#include <sys/stat.h>
#include<sys/types.h>
#include<unistd.h>
int main(void)
{
time_t now;
struct tm *tm_now;
char dt[200];
char x=0;
time(&now);
tm_now = localtime(&now);
strftime(dt, 200, "%x %X %Y-%m-%d", tm_now);
printf("now datetime : %s\n", dt);
char *s = strtok(dt," ");
s = strtok(NULL," ");
s = strtok(NULL," ");
const char *str = s;
mkdir(str,0777);
puts("输入 X 开始移动文件夹");
x=getchar();
if(x!=0)
{
pid_t pid = fork();
if(pid == 0)
{
execlp("mv","mv",str,"./pass",NULL);
return 0;
}
else
{
printf("文件已移动\n");
}
// execlp("mv","mv",str,"./pass",NULL); // method 1
}
return 0;
}bat:
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
md %ymd%
pause
move %ymd% C:\Users\Administrator\Desktop\pass
pause
标签:小代码
原文地址:http://wzsts.blog.51cto.com/10251779/1826753