Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Delete all files created in specific year Post 303036576 by drysdalk on Wednesday 3rd of July 2019 08:50:25 AM
Old 07-03-2019
Hi,

In theory, this should be fairly straightforward. If you want to delete all files created from 2017 and beyond (i.e. also files from 2016, 2015, etc - anything older than 2017), then you could do something like this:

Code:
find /path/to/files -type f -mtime +549 -exec rm -fv \{\} \;

That would find all files older than 549 days (at the time of writing, the number of days since December 31st 2017) and remove them.

Now, if you really want to only remove files from 2017, and only 2017, then it's slightly more complicated, but not much so. Assuming your version of find supports it, this would do the trick:

Code:
find /path/to/files -type f -newermt 2017-01-01 \! -newermt 2018-01-01 -exec rm -fv \{\} \;

This will very specifically remove files whose modification time is newer than 1st January 2017, but not newer than 1st January 2018 (in other words - files from 2017).

Hope this helps. Please test carefully before running this with a live rm command - swap it out for an ls or switch out the -exec for a -print first just to be sure it really is going to catch what you want, and only what you want, before turning this loose on your filesystem for real.
These 2 Users Gave Thanks to drysdalk For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete compressed files from year 2005

I'm trying to delete files that were created/modified in the year 2005 that we compressed and have the .Z extension on them. I tried using the awk utility but the syntax is incorrect. I don't know how to use a wildcard to capture all the compressed files. Here's the code I used ( ls -lR |... (5 Replies)
Discussion started by: igidttam
5 Replies

2. Filesystems, Disks and Memory

How to list files with specific created date

Hi, Would like to ask, which command is used to list all the files for specific date (says 1st May) and its size, for all files (including its subdirectory), in a mounted NFS disk to HP-UX. I would like to check for the total files came into my disk on 1st May. Very much appreciating your... (2 Replies)
Discussion started by: Draculla
2 Replies

3. Shell Programming and Scripting

Delete files created before specific date.

There is a system logging a huge amount of data and we need to delete some of the older logs .I mean the files that are created before one week from today. Here is a listing of files that are sitting there: /usr/WebSphere/AppServer/logs # ls -l -rw-r--r-- 1 root system 3740694 May... (5 Replies)
Discussion started by: moustafashawky
5 Replies

4. UNIX for Dummies Questions & Answers

Delete files by year

can someone provide a command to delete files by year? I have several files created last year 2009. Im trying to list first ls -lrt | grep '/2009/ {print $10}' by it returns no result. Pls advise (2 Replies)
Discussion started by: lhareigh890
2 Replies

5. Shell Programming and Scripting

Delete all the files and subdirectories for the year 2006

Hi I have lot of files and subdirectories inside a directory which are created in the years 2006, 2007, 2008, 2009 and 2010. I want to delete all the files and subdirectories belonging to the year 2006 alone. How can I do that ? (5 Replies)
Discussion started by: samsungsamsung
5 Replies

6. Shell Programming and Scripting

Delete files older than 1 year through FTP

Hi All, I want to login to a remote server using FTP command and then check for files older than 1 year and delete those files. Please let me know how can i achieve this using Unix Commands. Thanks in Advance, (10 Replies)
Discussion started by: HemaV
10 Replies

7. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

8. Shell Programming and Scripting

Delete files using year

Hi All, how can i delete files from my Unix directory on the basis of year, i have files from 2001 to till 2014, but from their, i have to delete only 2013 file.Below is my file name rwxrwxrwx 1 guopt users 5169 Jul 12 00:30 grt592_20130712003000.SAP Thanks Kki (2 Replies)
Discussion started by: kki
2 Replies

9. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

10. Shell Programming and Scripting

Files created on specific time

Hello Gurus, I am facing one issue to get a file for a specific time. There are about 300 files created between 6.30 pm to 7.15 pm everyday. Now I wanted only the file which is created on 6.45pm. No other files required. I have used "find" command to get the files, but not getting the expected... (3 Replies)
Discussion started by: pokhraj_d
3 Replies
mid3v2(1)						      General Commands Manual							 mid3v2(1)

NAME
mid3v2 - audio tag editor similar to 'id3v2' SYNOPSIS
mid3v2 [options] filename ... DESCRIPTION
mid3v2 is a Mutagen-based replacement for id3lib's id3v2. It supports ID3v2.4 and more frames; it also does not have the numerous bugs that plague id3v2. This program exists mostly for compatibility with programs that want to tag files using id3v2. For a more usable interface, we recommend Ex Falso. OPTIONS
-q, --quiet Be quiet: do not mention file operations that perform the user's request. Warnings will still be printed. -v, --verbose Be verbose: state all operations performed. This is the opposite of --quiet. This is the default. -f, --list-frames Display all supported ID3v2.3/2.4 frames and their meanings. -L, --list-genres List all ID3v1 numeric genres. These can be used to set TCON frames, but it is not recommended. -l, --list List all tags in the files. The output format is not the same as id3v2's; instead, it is easily parsable and readable. Some tags may not have human-readable representations. --list-raw List all tags in the files, in raw format. Although this format is nominally human-readable, it may be very long if the tag contains embedded binary data. -d, --delete-v2 Delete ID3v2 tags. -s, --delete-v1 Delete ID3v1 tags. -D, --delete-all Delete all ID3 tags. --delete-frames=FID1,FID2,... Delete specific ID3v2 frames (or groups of frames) from the files. -C, --convert Convert ID3v1 tags to ID3v2 tags. This will also happen automatically during any editing. -a, --artist=artist Set the artist information (TPE1). -A, --album=album Set the album information (TALB). -t, --song=title Set the title information (TIT2). -c, --comment=DESCRIPTION:COMMENT:LANGUAGE Set a comment (COMM). The language and description may be omitted, in which case the language defaults to English, and the descrip- tion to an empty string. -g, --genre=genre Set the genre information (TCON). -y, --year=, --date=YYYY-[MM-DD] Set the year/date information (TDRC). -Tnum/num, --track=num/num Set the track number (TRCK). Any text or URL frame (those beginning with T or W) can be modified or added by prefixing the name of the frame with "--". For example, --TIT3 "Monkey!" will set the TIT3 (subtitle) frame to Monkey!. BUGS
No sanity checking is done on the editing operations you perform, so mid3v2 will happily accept --TSIZ when editing an ID3v2.4 frame. How- ever, it will also automatically throw it out during the next edit operation. AUTHOR
Joe Wreschnig is the author of mid3v2, but he doesn't like to admit it. December 12th, 2009 mid3v2(1)
All times are GMT -4. The time now is 08:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy