Could it be possible to sort all of files in a folder and add z- to the name of the sorted file?
The names of the files to be sorted before the files are sorted
The names of the files to be sorted after the files are sorted
I'm using Windows 7 , Unix subsystems for Windows and C Shell
Could it be possible to sort all of files in a folder and add z- to the name of the sorted file?
The names of the files to be sorted before the files are sorted
The names of the files to be sorted after the files are sorted
I'm using Windows 7 , Unix subsystems for Windows and C Shell
Thank you!
I don't see any way of sorting filenames to get the order you have specified for the filenames to be processed, and I don't see why it matters which of the files are sorted first. If you just wanted to sort these four files (or all files whose filename starts with AC-), it would be a trivial task to do this using a standard shell.
Since you insist on using csh instead of bash or ksh or some other standard shell, I'll let someone else with more experience with more experience with csh syntax and semantics try to help you with a loop to do what you want.
It would help if you would show us what you have tried to solve this problem on your own. If you can code your own loop, the sort and mv or rm commands needed inside the loop won't vary much from shell to shell.
The filenames doesn't have to be sorted, only the files themselves need to be sorted and after sorting add z- to the beginning of the filename. It doesn't matter which of the files are sorted first. I have 2000 files in my folder. I only gave 4 examples of the filenames before.
So, you want to numerically sort the content of each file to create a new file with a prefix of z-. Is that correct?
You need a loop that uses all your file names and the processes them with something like:-
I'm not so sure of the foreach syntax in csh. The flags -bn asks sort to ignore blank/whitespace and sort numerically - which I think is what you want.
A reply to rbatte1. Yes, you have understood everything correctly. But I'm getting a error report in my C Shell window when I'm trying to use your code:
What to do?
Hi Team,
I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder.
Eg:
parent folder --> /Interface/data/test/IN
Sub folder -->/Interface/data/test/IN/Invoice20180607233338
Subfolder will be always with timestamp... (6 Replies)
I need help to write shell script to copy files from one server to another server.
Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Hi all.
I am very new to linux scripting and i have a task i can only solve with a script.
I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders.
Scenario:
Folder Path:... (1 Reply)
Hi all.
I am very new to linux scripting and i have a task i can only solve with a script.
I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders.
Scenario:
Folder Path:... (1 Reply)
Here is the code, but the list is not sorted properly (alphabetically)?
<?php
function folderlist(){
$startdir = './';
$ignoredDirectory = '.';
$ignoredDirectory = '..';
if (is_dir($startdir)){
if ($dh = opendir($startdir)){
while (($folder = readdir($dh)) !== false){
if... (0 Replies)
Hi all,
*I use Uwin and Cygwin emulator.
I´m trying to search for all text files in the current folder (C/Files) and its sub folders using
find -depth -name "*.txt"
The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Hi all,
I have copied all my files to one folder.and i want to check how many files (count) in the folder recently moved or total files in my folder?
please send me the query asap. (3 Replies)
Hi all,
I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt.
I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Hello all,
I'm trying to accomplish that if a file gets written to folder /path/to/a/ it gets automatically copied into /path/to/b/ the moment its get written.
I thought of writing a shell script and cron it that every X amount of minutes it copies these files over but this will not help me... (2 Replies)
hi
im having soo many .top files and i have to sort a set of files in one folder like tat so many sets of folders have to be created ... like say i have the file name j1 , g2 ,s3,k4,h1,j2,k3,s4..And i have to create one folder in tat i to have copy the files j1, g2 ,s3,k4 in one folder and... (0 Replies)