Sponsored Content
Top Forums Programming Script for creating a directory & move the .tif files in it. Post 302632687 by neutronscott on Monday 30th of April 2012 02:13:00 PM
Old 04-30-2012
Code:
#!/bin/bash

# minimum number of files per directory
cc=50
# directory prefix
dest_prefix=./LHR-
# starting suffix for directory (will be zero padded to 3 spaces)
d=1

for file in *.tif; do
        prefix=${file%%_*}

        # only increment destination if we've reached $cc AND
        #   it's a different prefix
        if ((++c > cc)) && [[ $prefix != $prev_prefix ]]; then
                ((c=1,d++))
        fi

        # zero pad destination directory
        printf -v dest "%s%03d" "$dest_prefix" "$d"

        # create destination directory
        mkdir -p "$dest"

        # verify functions correctly before moving stuff
        echo "[$c/$cc] $file -> $dest"
#       mv "$file" "$dest"

        prev_prefix=$prefix
done

This User Gave Thanks to neutronscott For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies

2. UNIX for Dummies Questions & Answers

sample script to archive & move previous day syslog files

hi all. Please help me with archiving previous day syslog files. the files have no extension and have the format YYYY-MM-DD. I want to archive the file then move it to some other machine. thanks. (2 Replies)
Discussion started by: coolatt
2 Replies

3. Shell Programming and Scripting

Script That Can navigate to 3 differents directory & remove files under them

Hi I am Trying to Write a script that can goto 4 different directorys on the server & remove the Files older then 30 days ?? /logs logs1 logs2 logs3 Now I need to remove files under logs1 logs2 logs3 which are older then 30 days whose name stat 'sit' , 'mig','bld' . in... (3 Replies)
Discussion started by: Beginner123
3 Replies

4. Shell Programming and Scripting

Script to move files to a directory according to date

hi all, here is the description to my problem. input parameter: $date1 based on the date i need to select three files starting with audit.log* based on its modified date, a date before, a date after(if its exists). We need to compare the input date to modified date of the file. And then... (3 Replies)
Discussion started by: ashrocks
3 Replies

5. Linux

Create folder by script & move files in it

Hi Team, I have over 1 lakh pdf files. I want to create folders like Disk-1, Disk-2 ..... & want to move 3000 pdfs per folder. Can i do it by script? Please help me. Thanks & Regards Parag Nehete (4 Replies)
Discussion started by: paragnehete
4 Replies

6. Shell Programming and Scripting

Script to search for a character in files in a Directory & remove it

Hi All, Am new to both Unix & this Forum - Need some help on a script that I am trying to write: In a Directory i have few text files which might or might not contain some text that I am trying to find. Once that text is found in any of the files, it needs to be removed from the file ... (6 Replies)
Discussion started by: rituparna_gupta
6 Replies

7. UNIX for Dummies Questions & Answers

Move Directory & Contents Between Two Machines

Hi All, I have a large amount of files that I need to copy from one server to another server using SFTP. Can comeone please help me with the command I would use here? Here is what I am thinking, but being new at this I know this is probably wrong: Login to the destination host using... (1 Reply)
Discussion started by: SalientAnimal
1 Replies

8. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

9. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

10. Shell Programming and Scripting

Need BASH Script Help to Move Files While Creating Directories

I've got this script to loop through all folders and move files that are more than 2 years old. I'm using the install command because it creates the necessary directories on the destination path and then I remove the source. I'd like to change the script to use the mv command since it is much... (4 Replies)
Discussion started by: consultant
4 Replies
starpkg(1)						      General Commands Manual							starpkg(1)

NAME
starpkg - convert a StarPlot data set to StarPlot file format SYNOPSIS
starpkg [ --dataset ] data-set [ --dest destination ] starpkg --recurse input-dir [ --dest destination ] DESCRIPTION
On the StarPlot web site are available some packages of data that include both an original data file from NASA, and also a specification file. These packages are referred to as "data sets", from which starconvert(1) can produce a data file in StarPlot format. For ease of use, this should be done via the starpkg shell script. USAGE
Assuming that data-set is a valid StarPlot data set (either in tar.gz format or a directory resulting from uncompressing the tar.gz file), the `starpkg --dataset' command converts it to a StarPlot-formatted data file. Note that the `--dataset' flag is optional, and the name of the input data set may be specified without it. In order to be a valid StarPlot data set, a directory or tar.gz file must contain at least a valid specification file whose name ends with `.spec' and a flat text data file named `catalog.dat'. If the `--dest' option is omitted, the default location of the output file is the first of the directories /usr/share/starplot, $PWD, $HOME in which the user has write permissions. If `--dest' is omitted or destination is a directory, the name of the output file will by default be ${specfilename%.spec}.stars. For instance, a data set containing gliese.3.spec will produce a file named gliese.3.stars. The `starpkg --recurse' form of the command executes the above action for every StarPlot data set contained in input-dir, placing the resulting StarPlot data files to the directory destination. (If the --dest option is omitted, the default destination directory is chosen as above.) This form of the starpkg command is most useful when a new version of StarPlot has been installed and you wish to regenerate all StarPlot data files from data sets using the new starconvert program. OPTIONS
--dataset, -s Specify a directory or tar.gz file to use as a StarPlot data set. --dest, -d Specify the file or directory in which to output StarPlot-format data files. --quiet, -q Print only fatal errors to the terminal. --recurse, -r Specify a directory in which to search for StarPlot data sets. --starconvert-option option Pass option through to starconvert. If you wish to pass more than one option (or an option that takes a following argument), you should give this flag multiple times, once for each starconvert option or argument. --verbose, -v Print all starconvert output to the terminal. SEE ALSO
starplot(1), starconvert(1) AUTHOR
Copyright (C) 2000-2002 under the GNU GPL by Kevin B. McCarty <starplot@starplot.org>. The StarPlot web page is at www.starplot.org. Nov 2002 starpkg(1)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy