Sponsored Content
Top Forums Shell Programming and Scripting File Move & Sort by Name - Kick out Bad File Names & More Post 302981768 by Nvizn on Monday 19th of September 2016 09:40:43 AM
Old 09-19-2016
File Move & Sort by Name - Kick out Bad File Names & More

I have a dilemma, we have users who are copying files to "directory 1." These images have file names which include the year it was taken. I need to put together a script to do the following:
  1. Examine the file naming convention, ensuring it's the proper format (e.g. test-1983_filename-123.tif) Ensuring the naming convention is in the correct format, doesn't include incorrect characters, filename out of order, etc. (this is in case a user adds a file/image with the incorrect naming convention)
  2. Rejects any images that are incorrectly named.
  3. Determine what year is in the filename (e.g. 1983)
  4. Search a different filesystem/location to see if that current directory exist (e.g. 1983 - year directory)
    1. If so, copying file to that location.
    2. If not, create directory (directory named year, e.g. 1983), then copy file to that location.


"Directory 1" will potentially have 1000's of files to process and sort.


I currently have a bash script that determines whether files exist within "directory 1," places them into a directory by today's date, then moves them to a different filesystem/location. I need the script to vet each filename, and move it to the respective directory named by the year. I'm most uncertain about how to vet the filenames. Any assistance is greatly appreciated!

Last edited by rbatte1; 09-19-2016 at 11:12 AM.. Reason: Converted text list into formatted numbered list with sub-lettered list and correcting spelling
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File Compare & Move between 2 servers

Greetings - I am a newbie in shell scripts. I have been thru the whole forum but there has been no similar query posed. The objective of my system is to have a unified filebase system. I am using RSync to synchronise files between the location & central server with both of them having the... (4 Replies)
Discussion started by: evolve
4 Replies

2. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

3. Shell Programming and Scripting

Sort & Split records in a file

Hi, I am new to scripting. I need a script to sort and the records in a file and then split them into different files. For example, the file is: H1...................... H2...................... D2.................... D2.................... H1........................... (15 Replies)
Discussion started by: Sunitha_edi82
15 Replies

4. Shell Programming and Scripting

cp && rm command, rm: <file> not removed. No such file or directory

Hi, I am running this is korn shell cp $source/$fname $dest/dir && rm $source/$fname This was returned: rm: /dir/file not removed: No such file or directory The file could be found in the $dest directory which meant the cp was success. The above code is used in a for loop to move... (5 Replies)
Discussion started by: Leion
5 Replies

5. UNIX for Dummies Questions & Answers

WebDav/davfs mounted file & directory names in all UPPERCASE

Hey, I have a WebDav directory mounted and everything seems fine except for one thing. All file/directory names appear in all UPPERCASE, when in actual fact they are lowercase on the remote machine. For example: foo/bar/baz.html on the remote host, appears on my local machine as... (0 Replies)
Discussion started by: MrMoney
0 Replies

6. UNIX for Dummies Questions & Answers

Search for & edit rows & columns in data file and pipe

Dear unix gurus, I have a data file with header information about a subject and also 3 columns of n rows of data on various items he owns. The data file looks something like this: adam peter blah blah blah blah blah blah car 01 30 200 02 31 400 03 57 121 .. .. .. .. .. .. n y... (8 Replies)
Discussion started by: tintin72
8 Replies

7. Shell Programming and Scripting

replace & with &amp; xml file

Hello All I have a xml file with many sets of records like this <mytag>mydata</mytag> <tag2>data&</tag2> also same file can be like this <mytag>mydata</mytag> <tag2>data&</tag2> <tag3>data2&amp;data3</tag3> Now i can grep & and replace with &amp; for whole file but it will replace all... (4 Replies)
Discussion started by: lokaish23
4 Replies

8. Shell Programming and Scripting

Archive & move the file

I have a set of files in path /ifx01/etldata/lmt/ a.xml b.xml I have to archive & move these files to path /ifx01/etldata/archive ,so that not even the original files should exists. After acrhiving there should be no files in path /ifx01/etldata/lmt/ (6 Replies)
Discussion started by: jagadeeshn04
6 Replies

9. Shell Programming and Scripting

Sort a the file & refine data column & row format

cat file1.txt field1 "user1": field2:"data-cde" field3:"data-pqr" field4:"data-mno" field1 "user1": field2:"data-dcb" field3:"data-mxz" field4:"data-zul" field1 "user2": field2:"data-cqz" field3:"data-xoq" field4:"data-pos" Now i need to have the date like below. i have just... (7 Replies)
Discussion started by: ckaramsetty
7 Replies

10. Shell Programming and Scripting

Want to sort a file using awk & sed to get required output

Hi All, Need Suggestion, Want to sort a file using awk & sed to get required, output as below, such that each LUN shows correct WWPN and FA port Numbers correctly: Required output: 01FB 10000000c97843a2 8C 0 01FB 10000000c96fb279 9C 0 22AF 10000000c97843a2 8C 0 22AF 10000000c975adbd ... (10 Replies)
Discussion started by: aix_admin_007
10 Replies
asetmasters(4)							   File Formats 						    asetmasters(4)

NAME
asetmasters, tune.low, tune.med, tune.high, uid_aliases, cklist.low, cklist.med, cklist.high - ASET master files SYNOPSIS
/usr/aset/masters/tune.low /usr/aset/masters/tune.med /usr/aset/masters/tune.high /usr/aset/masters/uid_aliases /usr/aset/masters/cklist.low /usr/aset/masters/cklist.med /usr/aset/masters/cklist.high DESCRIPTION
The /usr/aset/masters directory contains several files used by the Automated Security Enhancement Tool (ASET). /usr/aset is the default operating directory for ASET. An alternative working directory can be specified by the administrators through the aset -d command or the ASETDIR environment variable. See aset(1M). These files are provided by default to meet the need of most environments. The administrators, however, can edit these files to meet their specific needs. The format and usage of these files are described below. All the master files allow comments and blank lines to improve readability. Comment lines must start with a leading "#" character. tune.low These files are used by the tune task (see aset(1M)) to restrict the permission settings for system objects. Each file is tune.med used by ASET at the security level indicated by the suffix. Each entry in the files is of the form: tune.high pathname mode owner group type where pathname is the full pathname mode is the permission setting owner is the owner of the object group is the group of the object type is the type of the object It can be symlink for a symbolic link, directory for a directory, or file for everything else. Regular shell wildcard ("*", "?", ...) characters can be used in the pathname for multiple references. See sh(1). The mode is a five-digit number that represents the permission setting. Note that this setting represents a least restrictive value. If the current setting is already more restrictive than the specified value, ASET does not loosen the permission settings. For example, if mode is 00777, the permission will not be changed, since it is always less restrictive than the current setting. Names must be used for owner and group instead of numeric ID's. ? can be used as a "don't care" character in place of owner, group, and type to prevent ASET from changing the existing values of these parameters. uid_alias This file allows user ID's to be shared by multiple user accounts. Normally, ASET discourages such sharing for accountabil- ity reason and reports user ID's that are shared. The administrators can, however, define permissible sharing by adding entries to the file. Each entry is of the form: uid=alias1=alias2=alias3= ... where uid is the shared user id alias? is the user accounts sharing the user ID For example, if sync and daemon share the user ID 1, the corresponding entry is: 1=sync=daemon cklist.low These files are used by the cklist task (see aset(1M)), and are created the first time the task is run at the low, medium, cklist.med and high levels. When the cklist task is run, it compares the specified directory's contents with the appropriate cklist.high cklist.level file and reports any discrepancies. EXAMPLES
Example 1: Examples of Valid Entries for the tune.low, tune.med, and tune.high Files The following is an example of valid entries for the tune.low, tune.med, and tune.high files: /bin 00777 root staffsymlink /etc 02755 root staffdirectory /dev/sd* 00640 rootoperatorfile SEE ALSO
aset(1M), asetenv(4) ASET Administrator Manual SunOS 5.10 13 Sep 1991 asetmasters(4)
All times are GMT -4. The time now is 02:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy