Zenity and bulk file movements


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Zenity and bulk file movements
# 1  
Old 03-10-2018
Zenity and bulk file movements

Hi all.

Total beginner to Zenity.
I've plagiarised bits of code from all over to try to get something to work.

The story:
I have a directory with maybe 10-15 files in it, each about 200MB.
i send these files one at a time to a drive about 15 miles away. The Synology sync can only handle one file at a time, as because there is no high speed line, the file takes about an hour to send. More than 1 file at a time, and Synology can't handle it.
I send at night using the script below.
Code:
#!/bin/bash
(
cd ~/Downloads
d1="$(zenity  --file-selection --title="Bulk Move    Choose starting directory"  --directory)"
d2="$(zenity  --file-selection --title="Bulk Move    Choose destination directory"  --directory)"
delay="$(zenity --entry --title="Bulk Move" --text="Enter delay in minutes:")"
result=`echo "$delay *60" | bc`
find "$d1"/* -exec mv {} "$d2" \; -exec sleep "$result" \;

) | zenity --title="Timed Bulk Move in progress" --progress --pulsate --auto-close &

# get zenity process id
PID_ZENITY=${!}

# get firstly created child process id, which is running all tasks
PID_CHILD=$(pgrep -o -P $$)

# loop to check that progress dialog has not been cancelled
while [ "$PID_ZENITY" != "" ]
do
  # get PID of all running tasks
  PID_TASKS=$(pgrep -d ' ' -P ${PID_CHILD})

  # check if zenity PID is still there (dialog box still open)
  PID_ZENITY=$(ps h -o pid --pid ${PID_ZENITY} | xargs)

  # sleep for 2 second
  sleep 2
done

# if some running tasks are still there, kill them
[ "${PID_TASKS}" != "" ] && kill -9 ${PID_TASKS}
zenity --info --text "Move Completed"

I have not put things in the right place, as when the last file is gone, it counts another delay until it completes.

I would dearly love the progress bar to count up as the delay completes, but have not got a clue. Sitting looking at a Cylon for 45 minutes ain't doing me any good.


Moderator's Comments:
Mod Comment Please use CODE (not ICODE) tags as required by forum rules!

Last edited by RudiC; 03-10-2018 at 01:31 PM.. Reason: Changed ICODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bulk changing of file names using Terminal in OS X

I want to change the name of several files within a folders (directory) and subdirectories in OS X. If I only wanted to change file names within the directory I guess I would use: rm photo*.jpg picture*.jpg I have lots of subdirectories, is there a way of getting the file changes for all... (5 Replies)
Discussion started by: ademanuele
5 Replies

2. Shell Programming and Scripting

How to select bulk of info from log file?

unix : sun shell : bash i need to select multiple rows with this format : <special format> 10 lines /<special format> from log file that have lots of info i thought of getting the number of the first line using grep -n "special format" file | cut -d: -f1 then pass it to shell... (2 Replies)
Discussion started by: scorpioneer
2 Replies

3. Shell Programming and Scripting

How to bulk changing partial file name in Linux?

I have a bunch of database files in a directory. Their name are like: 1234_ABCD_01.dbf, 28hrs_ABCD_02.dbf I want to change them in bulk to: 1234_XXXU_01.dbf, 28hrs_XXXU_02.dbf. I mean I just want to replace ABCD by XXXU. don't change other part of the file name and the contents of the... (4 Replies)
Discussion started by: duke0001
4 Replies

4. Shell Programming and Scripting

Loop through text file > Copy Folder > Edit XML files in bulk?

I have a text file which contains lines in this format - it contains 105 lines in total, but I'm just putting 4 here to keep it short: 58571,east_ppl_ppla_por 58788,east_pcy_hd_por 58704,east_pcy_ga_por 58697,east_pcy_pcybs_por It's called id_key.txt I have a sample folder called... (9 Replies)
Discussion started by: biscuitcreek
9 Replies

5. Shell Programming and Scripting

file zenity

Hello, I have a script with zenity file, but I want to know the file name and path, but this way I just take the name of the file. fl1=`zenity --file-selection --title="Seleccionar fichero"` basename $fl1 .txt > temp nom=`cat temp` Thank you very much (1 Reply)
Discussion started by: uri_crack
1 Replies

6. Shell Programming and Scripting

Creating Header & Trailer for bulk volume data file

Hi all, I have a requirement to create a Header &Trailer for a file which is having 20 millions of records. If I use the following method, i think it will take more time. cat "Header"> file1.txt cat Data_File>>file1.txt cat "Trailer">>file1.txt since second CAT command has to read all... (4 Replies)
Discussion started by: Raamc
4 Replies

7. Shell Programming and Scripting

Need help renaming bulk file extentions

Hello, I am trying to rename bulk files however i dont think the rename/mv command is giong to help me here. here is a quick snapshot of the files I need to rename: 75008040 -rw-r----- 1 root root 8716 May 8 05:00 10.9.144.2 75008041 -rw-r----- 1 root root 11700 May 8 05:00 10.9.160.2... (10 Replies)
Discussion started by: jallan
10 Replies

8. Shell Programming and Scripting

Using 'stat' to determine file system type (with Zenity)

edited and removed (0 Replies)
Discussion started by: mdpalow
0 Replies

9. Shell Programming and Scripting

extract bulk emails into a single flat file

Hello Can someone guide me how to extract bulk emails into a single flat file ? We receive mails (approx 1K daily ). I want the contents of the emails for 'current date' to be dumped into one single text file. Please help. (1 Reply)
Discussion started by: Amruta Pitkar
1 Replies

10. Programming

How to read specific lines in a bulk file using C file Programming

Please Help me I have a Bulk file containing Hex data I want to read specific lines from that bulk file by ID number. example ID DATE Time data 14 2005/09/28 07:40:08.546 0 5 078B1C 01916C 0FE59C 004B54 0A9670 0D04ED 05B6B4 0E2223... (10 Replies)
Discussion started by: rajan_ka1
10 Replies
Login or Register to Ask a Question