날짜를 변경할 수 있는 방법이 있는 파일이 수정 / 작성 (Nautilus 또는 함께 나와 있는 ls - l 명령)? 이상적인 찾고 있습니다 수 있는 다양한 파일 날짜 / 시간 스탬프를 변경하십시오 명령을 한 전체 일정 시간 앞 또는 뒤로 (예를 들면 +8 시간 또는 - 4 일 등).
As long as you are the 파일의 소유자가 (또는 루트) '터치' 명령을 사용하여 파일의 수정 시간을 변경할 수 있습니다.
touch filename
이 설정은 기본적으로 이 시간 현재 시간으로 file& # 39 의 수정, - d '기' 와 같은 여러 수축됐는데 플래깅 특정 날짜를 선택할 수 있습니다. 예를 들어, 2 시간 전에 미리 설정할 수 있는 파일 部门是这样的 수정되었음 다음 사용할 수 있습니다.
touch -d "2 hours ago" filename
파일을 수정할 경우 기존 수정 시간을 기준으로 다음 어떻게해야합니다 대신 이 트릭.
touch -d "$(date -R -r filename) - 2 hours" filename
많은 수의 파일을 수정할 경우 다음 사용할 수 있습니다.
find DIRECTORY -print | while read filename; do
# do whatever you want with the file
touch -d "$(date -R -r "$filename") - 2 hours" "$filename"
done
'너' 를 찾기 위해 인수만 변경할 수 있습니다 파일만 관심이 모아지고 있다. 파일 수정 시간 업데이트하려는 경우에만 이를 기준으로 현재 시간과 단순화할 수 있습니다.
find DIRECTORY -exec touch -d "2 hours ago" {} +
대부분의 리눅스 파일 시스템 시간을 최대한 익스포트를 댁이라면 이 값을 추적하는 마십시오. There is a '스타임' 연관됨 파일을 파일 메타데이터를 추적하고, 그 때 마지막으로 바뀌었다. 변경된 파일의 경우 발생할 수 있는 권한을 갖고 있지만, 그것은 결코 우연의 이 생성 시간을 갖는다. 파일 수정 시간 들려주시겠습니까 직접 변경하는 등 부작용이 업데이트하려면 '스타임' 메타데이터입니다 바꼈소, 수도 있을 것입니다.
참 고맙네요. 이 협력했습니다 가져다줄래요:
에 대한 털미널 gnu. orghttp://www. 디렉토리에는 날짜 편집. 그럼 유형:
find -print | while read filename; do
# do whatever you want with the file
touch -t 201203101513 "$filename"
done
이 > " " 볼 수 있습니다;;; 에스페트 > enter 후에는 마지막으로 -; done" ";).
참고: &Quot " 변경할 수 있습니다. 201203101513.
" ". 201203101513. = 는 날짜 운영까지도 모든 파일에 대해 이 디렉터리입니다.
액세스되며 수정되었음 쉽게 같습니다.
touch -a -m -t 201512180130.09 fileName.ext
여기서:
-a = accessed
-m = modified
-t = timestamp - use [[CC]YY]MMDDhhmm[.ss] time format
'지금' 그냥 '-t 및 사용하려면 드롭합니다 타임스탬프와.
그들은 모두 같은 확인할 수 있다. '당장' filename. ext
참조: 터치 양반이군요
`-r FILE' `--reference=FILE'
Use the times of the reference FILE instead of the current time.
If this option is combined with the `--date=TIME' (`-d TIME')
option, the reference FILE's time is the origin for any relative
TIMEs given, but is otherwise ignored. For example, `-r foo -d
'-5 seconds'' specifies a time stamp equal to five seconds before
the corresponding time stamp for `foo'. If FILE is a symbolic
link, the reference timestamp is taken from the target of the
symlink, unless `-h' was also in effect.
예를 들어, 8 시간 추가 맞추기바인딩 file& # 39 의 날짜 (파일_이름 만일의 사태에 대비해 '공백' 의 말을 인용해 파일 등).
touch -r "file" -d '+8 hour' "file"
루프를 사용하는 모든 파일을 통해 현재 방향:
for i in *; do touch -r "$i" -d '+8 hour' "$i"; done
예를 들어, 모든 파일을 찾을 수 있는 파일 이름 '시작' s '를 추가하고, 어느 날 그 누구의 스타디르 file& # 39 의 수정날짜 시간스탬프와 사용합니다.
find thatdir -name "s*" -print0 | xargs -0 -I '{}' touch -r '{}' -d '+1 day' '{}'
적어도 이 작은 스크립트입니다 작동됨 가져다줄래요
#!/bin/bash
# find specific files
files=$(find . -type f -name '*.JPG')
# use newline as file separator (handle spaces in filenames)
IFS=$'\n'
for f in ${files}
do
# read file modification date using stat as seconds
# adjust date backwards (1 month) using date and print in correct format
# change file time using touch
touch -t $(date -v -1m -r $(stat -f %m "${f}") +%Y%m%d%H%M.%S) "${f}"
done
아마도 이것은 쉬운 일이 아니지만, 난 매우 간단한 방법을 찾을 didn& # 39, t do it.
내가 여기서 찾을 수 있는 날짜를 수정하십시오 스크립트입니다 수정되었음 내가 처음 사용한 1 월입니다.
#!/bin/bash
# find specific files
files=$(find . -type f -name '*.JPG')
# use newline as file separator (handle spaces in filenames)
IFS=$'\n'
for f in ${files}
do
# read file modification date using stat as seconds
# adjust date backwards (1 month) using date and print in correct format
# change file time using touch
touch -t $(date -v -1m -r $(stat -f %m "${f}") +%Y%m%d%H%M.%S) "${f}"
done
#!/bin/bash
# find specific files
#files=$(find . -type f -name '*.JPG')
# use newline as file separator (handle spaces in filenames)
IFS=$'\n'
for f in $*
do
# read file modification date using stat as seconds
# adjust date backwards (1 month) using date and print in correct format
# change file time using touch
touch -t $(date -v +1y -r $(stat -f %m "${f}") +2014%m%d%H%M.%S) "${f}"
done
내가 지금 내가 할 수 있는 일을 했다는 것을 좀 더 일반적인 버전:
#!/bin/bash
# find specific files
#files=$(find . -type f -name '*.JPG')
# use newline as file separator (handle spaces in filenames)
IFS=$'\n'
for f in $*
do
# read file modification date using stat as seconds
# adjust date backwards (1 month) using date and print in correct format
# change file time using touch (+1y adds a year "-1y" subtracts a year)
# Below line subtracts a year
touch -t $(date -v -1y -r $(stat -f %m "${f}") +%Y%m%d%H%M.%S) "${f}"
# Below line adds a year
# touch -t $(date -v +1y -r $(stat -f %m "${f}") +%Y%m%d%H%M.%S) "${f}"
done
이 파일을 사용하여 사용자가 필요로 하는 쓸 및
chmod +x fn
실행할 수 있습니다.
./fn files-to-change
fn = 해당 파일 이름이 관리
예
./fn *.JPG
1 년에 디렉터리입니다 날짜를 변화시킬 수 있습니다.