讓每個檔案的修改時間差一秒 - Linux

By Carol
at 2016-07-11T01:34
at 2016-07-11T01:34
Table of Contents
※ 引述《LIAR (玻璃做的大叔)》之銘言:
: 我因為windows檔案管理的關係,有時要用檔名,有時要用時間排序,
: 因此新檔案進來後我會先丟到linux裡面用touch調整時間。
: 現在我希望讓大量檔案的mtime只差一秒,我想過
: find *.mp4 -exec touch {} \;
: mtime差距太短
: find *.mp4 -exec sleep 1 && touch {} \;
: 語法執行錯誤,exec後面不能接 && 或是 ; 啊??
: 請問這種有辦法用bash辦到嗎?
檔案多 sleep 你會等超久~~~~
bash 還有一招
time=`date +'%s'`
find /path -name '*.mp4' | while read f
do
touch -d "1970-01-01 00:00:00 ${time}sec GMT" "$f"
time=`expr $time + 1`
done
--
: 我因為windows檔案管理的關係,有時要用檔名,有時要用時間排序,
: 因此新檔案進來後我會先丟到linux裡面用touch調整時間。
: 現在我希望讓大量檔案的mtime只差一秒,我想過
: find *.mp4 -exec touch {} \;
: mtime差距太短
: find *.mp4 -exec sleep 1 && touch {} \;
: 語法執行錯誤,exec後面不能接 && 或是 ; 啊??
: 請問這種有辦法用bash辦到嗎?
檔案多 sleep 你會等超久~~~~
bash 還有一招
time=`date +'%s'`
find /path -name '*.mp4' | while read f
do
touch -d "1970-01-01 00:00:00 ${time}sec GMT" "$f"
time=`expr $time + 1`
done
--
Tags:
Linux
All Comments

By Hedy
at 2016-07-12T09:25
at 2016-07-12T09:25

By Tracy
at 2016-07-14T16:08
at 2016-07-14T16:08

By Dora
at 2016-07-17T03:05
at 2016-07-17T03:05

By Dora
at 2016-07-19T14:29
at 2016-07-19T14:29

By Rosalind
at 2016-07-22T08:10
at 2016-07-22T08:10

By Iris
at 2016-07-22T10:05
at 2016-07-22T10:05

By Edward Lewis
at 2016-07-23T19:52
at 2016-07-23T19:52

By Jessica
at 2016-07-24T14:30
at 2016-07-24T14:30

By Noah
at 2016-07-25T12:22
at 2016-07-25T12:22

By Genevieve
at 2016-07-30T09:45
at 2016-07-30T09:45

By Quintina
at 2016-07-31T08:36
at 2016-07-31T08:36

By Eartha
at 2016-08-02T07:41
at 2016-08-02T07:41

By Mia
at 2016-08-05T06:19
at 2016-08-05T06:19

By Sandy
at 2016-08-06T16:17
at 2016-08-06T16:17

By Adele
at 2016-08-07T13:27
at 2016-08-07T13:27
Related Posts
讓每個檔案的修改直接差一秒

By Brianna
at 2016-07-10T10:45
at 2016-07-10T10:45
systemd

By Andrew
at 2016-07-09T23:47
at 2016-07-09T23:47
Windows CentOS 雙系統怎麼裝?

By Rebecca
at 2016-07-09T20:08
at 2016-07-09T20:08
systemd

By Aaliyah
at 2016-07-09T19:59
at 2016-07-09T19:59
posfix header_checks 的規則寫法請教

By Kumar
at 2016-07-08T21:31
at 2016-07-08T21:31