Sponsored Content
Top Forums UNIX for Dummies Questions & Answers move files that match specific conditions Post 302720573 by rdrtx1 on Wednesday 24th of October 2012 11:55:23 AM
Old 10-24-2012
try:
Code:
 
names=(32983_f 35416_f 43579_f) # these are the names of directories where I want to copy the files to
for i in ${names[@]}
do
  if [ -f /Users/name/Dropbox/$i_exp.txt ]; then
    # _exp.txt is the constant part of the files I want to move
    [[ -d /Users/name/Desktop/SUBJ/$i ]] || mkdir -p /Users/name/Desktop/SUBJ/$i
    cp /Users/name/Dropbox/$i_exp.txt /Users/name/Desktop/SUBJ/$i
    # I want that this file is copied in the corresponding directory (with the same initial 5 numbers as the file)
  fi
done


Last edited by rdrtx1; 10-24-2012 at 01:15 PM.. Reason: fixed spacing around square brackets.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep'ing for specific directories, and using the output to move files

Hello, this is probably another really simple tasks for most of you gurus, however I am trying to make a script which takes an input, greps a specific file for that input, prints back to screen the results (which are directory names) and then be able to use the directory names to move files.... (1 Reply)
Discussion started by: JayC89
1 Replies

2. Shell Programming and Scripting

Find files that do not match specific patterns

Hi all, I have been searching online to find the answer for getting a list of files that do not match certain criteria but have been unsuccessful. I have a directory that has many jpg files. What I need to do is get a list of the files that do not match both of the following patterns (I have... (21 Replies)
Discussion started by: nikos-koutax
21 Replies

3. Shell Programming and Scripting

Recursively move directories along with files/specific files

I would like to transfer all files ending with .log from /tmp and to /tmp/archive (using find ) The directory structure looks like :- /tmp a.log b.log c.log /abcd d.log e.log When I tried the following command , it movies all the log files... (8 Replies)
Discussion started by: frintocf
8 Replies

4. Shell Programming and Scripting

How to match the below conditions?

Hello All, I have 2 files with around 2k records.. I am lost how to build a script to create another file with the below:confused::eek: Match Condition1: File1's 12th Columns data should exact match with File2's 19th Column's data Match Condition2: File1's 28th Column's data format is... (12 Replies)
Discussion started by: ailnilanjan
12 Replies

5. Shell Programming and Scripting

Bash to move specific files from folders in find file

I have a directory /home/cmccabe/nfs/exportedReports that contains multiple folders in it. The find writes the name of each folder to out.txt. A new directory is then created in a new location /home/cmccabe/Desktop/NGS/API, named with the date. What I am trying to do, unsuccessfully at the moment,... (7 Replies)
Discussion started by: cmccabe
7 Replies

6. Shell Programming and Scripting

awk to match field between two files and use conditions on match

I am trying to look for $2 of file1 (skipping the header) in $2 of file2 (skipping the header) and if they match and the value in $10 is > 30 and $11 is > 49, then print the line from file1 to a output file. If no match is foung the line is not printed. Both the input and output are tab-delimited.... (3 Replies)
Discussion started by: cmccabe
3 Replies

7. Shell Programming and Scripting

Insert a newline after match in files of specific name under some subdirectories?

Hi I'd like to add the newline: \tuser: nobody", or "<TAB>user: nobody to all files named: docker-compose.ymlin subfolders of pwd with names beginning with 10-20. Within these files, I'd like to find the line (there'll only be one) containing: command: celery workerNOTE: As far as... (2 Replies)
Discussion started by: duncanbetts
2 Replies

8. Shell Programming and Scripting

awk to print fields that match using conditions and a default value for non-matching in two files

Trying to use awk to match the contents of each line in file1 with $5 in file2. Both files are tab-delimited and there may be a space or special character in the name being matched in file2, for example in file1 the name is BRCA1 but in file2 the name is BRCA 1 or in file1 name is BCR but in file2... (6 Replies)
Discussion started by: cmccabe
6 Replies

9. Shell Programming and Scripting

Bash to move specific files to directory based on match to file

I am trying to mv each of the .vcf files in the variants folder to the folder in /home/cmccabe/f2 that the .vcf id is found in file. $2 in file will always have the id of a .vcf in the variants folder. The line in blue staring with R_2019 in file up to the -v5.6 will always be an exact match to a... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. UNIX for Beginners Questions & Answers

Move several files into specific directories with a loop

Hello, I'm a first time poster looking for help in scripting a task in my daily routine. I am new in unix but i am attracted to its use as a mac user. Bear with me... I have several files (20) that I manually drag via the mouse into several named directories over a network. I've used rsync... (14 Replies)
Discussion started by: SonnyClark
14 Replies
Net::Dropbox::API(3pm)					User Contributed Perl Documentation				    Net::Dropbox::API(3pm)

NAME
Net::Dropbox::API - A dropbox API interface VERSION
Version 1.8.8.8 SYNOPSIS
The Dropbox API is a OAuth based API. I try to abstract as much away as possible so you should not need to know too much about it. This is how it works: use Net::Dropbox::API; my $box = Net::Dropbox::API->new({key => 'KEY', secret => 'SECRET'}); my $login_link = $box->login; # user needs to click this link and login $box->auth; # oauth keys get exchanged my $info = $box->account_info; # and here we have our account info See the examples for a working Mojolicious web client using the Dropbox API. You can find Dropbox's API documentation at <https://www.dropbox.com/developers/web_docs> FUNCTIONS
login This sets up the initial OAuth handshake and returns the login URL. This URL has to be clicked by the user and the user then has to accept the application in dropbox. Dropbox then redirects back to the callback URL defined with "$self->callback_url". If the user already accepted the application the redirect may happen without the user actually clicking anywhere. auth The auth method changes the initial request token into access token that we need for subsequent access to the API. This method only has to be called once after login. account_info account_info polls the users info from dropbox. list lists all files in the path defined: $data = $box->list(); # top-level $data = $box->list( "/Photos" ); # folder The data returned is a ref to a hash containing various fields returned by Dropbox, including a "hash" value, which can be used later to check if Dropbox data beneath a specified folder has changed since the last call. For this, "list()" accepts an optional 'hash' argument: $data = $box->list({ hash => "ce9ccbfb8f255f234c93adcfef33b5a6" }, "/Photos"); This will either return { http_response_code => 304 } in which case nothing has changed since the last call, or { http_response_code => 200, # ... various other fields } if there were modifications. copy copies a folder copy($from, $to) move move a folder move($from, $to) mkdir creates a folder mkdir($path) delete delete a folder delete($path) view creates a cookie protected link for the user to look at. view($path) metadata creates a cookie protected link for the user to look at. metadata($path) putfile uploads a file to dropbox getfile get a file from dropbox debug Set this to a non-false value in order to print some debugging information to STDOUT. debug(1) INTERNAL API
_talk _talk handles the access to the restricted resources. You should normally not need to access this directly. nonce Generate a different nonce for every request. AUTHOR
Lenz Gschwendtner, "<norbu09 at cpan.org>" With Bug fixes from: Greg Knauss "gknauss at eod.com" Chris Prather "chris at prather.org" Shinichiro Aska [ktdreyer] SureVoIP <http://www.surevoip.co.uk> BUGS
Please report any bugs through the web interface at https://github.com/norbu09/Net--Dropbox/issues <https://github.com/norbu09/Net--Dropbox/issues>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
You can find documentation for this module with the perldoc command. perldoc Net::Dropbox::API You can also look for information at: o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Net-Dropbox-API <http://annocpan.org/dist/Net-Dropbox-API> o CPAN Ratings http://cpanratings.perl.org/d/Net-Dropbox-API <http://cpanratings.perl.org/d/Net-Dropbox-API> o Search CPAN http://search.cpan.org/dist/Net-Dropbox-API/ <http://search.cpan.org/dist/Net-Dropbox-API/> COPYRIGHT &; LICENSE Copyright 2010 Lenz Gschwendtner. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. perl v5.14.2 2012-03-22 Net::Dropbox::API(3pm)
All times are GMT -4. The time now is 08:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy