Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to create a summary file of all files in a directory sorted in reverse alphabetical order.? Post 302986633 by Braveheart on Monday 28th of November 2016 01:15:49 PM
Old 11-28-2016
How to create a summary file of all files in a directory sorted in reverse alphabetical order.?

I have an interactive script which works terrific at processing a folder of unsorted files into new directories.

I am wondering how I could modify my script so that( upon execution) it provides an additional labelled summary file on my desktop that lists all of the files in each directory that the script has sorted in reverse alphabetical order.

NB. The script as it stands is executed on an unsorted folder containing (jpg,gif,docx, aif, wav).The script runs and moves all files of type jpg, gif,docx to newly formed directories and everything else gets bumped into a miscellaneous. I would like a summary file on the desktop that lists all of these files in reverse alphabetical order based on the executed sort process that has finalised.

Code:
#!/bin/bash
read -p "Good Morning, Please enter your file type name for sorting [ENTER]:" all_extensions
if cd /Users/christopherdorman/desktop
  then	while read extension
	  do 	destination="folder$extension"
	  	mkdir -p "$destination"
	  	mv  -v unsorted/*."$extension" "$destination"
	  done   <<< "${all_extensions// /$'\n'}"
		mkdir -p foldermisc	
		if mv  -v unsorted/* "foldermisc"
	  then	echo "Good News, the rest of Your files have been successfully processed"
		fi
	for i in folder*/; do
  		ls -S "$i" > "${i}filelist"
	done
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort a file in reverse order

I a file with log entries... I want to sort it so that the last line in the file is first and the first line is last.. eg. Sample file 1 h a f 8 6 After sort should look like 6 8 f a h 1 (11 Replies)
Discussion started by: frustrated1
11 Replies

2. Shell Programming and Scripting

executing code on files in the sorted order -help!

Say i have 2 files in the giving format: file1 1 2 3 4 1 2 3 4 1 2 3 4 file2 1 2 3 4 1 2 3 4 1 2 3 4 I have a PERL code (loaned by one of u -i forgot who - thanks!) that extracts the 2nd column from each file and append horizontally to a new file: perl -ane 'push @{$L->}, $F; close... (1 Reply)
Discussion started by: epi8
1 Replies

3. Shell Programming and Scripting

alphabetical order with out using sort command

hai, how can i sort a file alphabetically without using sort command (6 Replies)
Discussion started by: rahul801
6 Replies

4. UNIX for Dummies Questions & Answers

How can I list the file under a directory both in alphabetical and in reverse alphabetical order?

How can I list the file under current directory both in alphabetical and in reverse alphabetical order? (1 Reply)
Discussion started by: g.ashok
1 Replies

5. Shell Programming and Scripting

Counts a number of unique word contained in the file and print them in alphabetical order

What should be the Shell script that counts a number of unique word contained in a file and print them in alphabetical order line by line? (7 Replies)
Discussion started by: proactiveaditya
7 Replies

6. Shell Programming and Scripting

sort the files based on timestamp and execute sorted files in order

Hi I have a requirement like below I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory My files looks like this PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies

7. Shell Programming and Scripting

[SHELL] Userlist alphabetical order

Hi everyone! I am new to the forum and have recently started working with Linux. Quick question, I want a user list in alphabetical order as the output of a shell script. Who can help me!? Thanks! From the netherlands ;) (5 Replies)
Discussion started by: dennisbest85
5 Replies

8. UNIX for Dummies Questions & Answers

Script to list applications in alphabetical order

I've looking over a script for work and I've had a problem with the script not listing the files in alphabetical order. To look up PIDs for apps, it would be beneficial to have them listed in that order. Here is what I've been reviewing. #!/usr/bin/perl $str = sprintf "%4s %-40s", "PID",... (7 Replies)
Discussion started by: whysolucky
7 Replies

9. Shell Programming and Scripting

Sorting lines between patterns in alphabetical order

Hi, need help in sorting lines between strings "<section status = “ole-service”>" and "</section>" in alphabetical order, based on the text in red. Hoping for an AWK or SED solution. Thank you. ... <section status = “ole-service”>... <p service = "OOO">XZZ</p> <p service = "AAA">AAA... (3 Replies)
Discussion started by: pioavi
3 Replies

10. Shell Programming and Scripting

Want to grep records in alphabetical order from a file and split into other files

Hi All, I have one file containing thousands of table names in single column. Now I want that file split into multiple files e.g one file containing table names starting from A, other containing all tables starting from B...and so on..till Z. I tried below but it did not work. for i in... (6 Replies)
Discussion started by: shekhar_4_u
6 Replies
All times are GMT -4. The time now is 12:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy