File Download from Sharepoint folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Download from Sharepoint folder
# 1  
Old 08-01-2017
File Download from Sharepoint folder

Hi All,

Please let me know the simple script to download the latest .xlsx file from the share point folder.

I am using the CURL command and which is working fine if give the particular file name. But I have the list of files with the timestamp.'

Ex :
Code:
Filename_07202017.xlsx
Filename_07102017.xlsx

I should pick only the latest one which is Filename_07202017.

Thank you.

Last edited by rbatte1; 08-02-2017 at 05:41 AM.. Reason: Added CODE tags
# 2  
Old 08-01-2017
Code:
NAME=$(sort -r < list | head -n 1)

# 3  
Old 08-01-2017
Quote:
Originally Posted by Corona688
Code:
NAME=$(sort -r < list | head -n 1)

Since the year comes after the month and day in the timestamps in these filenames, the sort needs to be a little more complicated (and assuming that the filename prefix does not contains any other _s):
Code:
NAME=$(sort -r -t_ -k2.4,2.8 -k2.1,2.4 list | head -n 1)

assuming that there is only one filename before the underscore in your list. If there are multiple filename prefixes in your list, you'll need a loop something like:
Code:
last=
sort -t_ -k1,1 -k2.4,2.8r -k2.1,2.4r list | while IFS=_ read -r filename time
do	if [ "$last" = "$filename" ]
	then	continue
	fi
	curl other_parameters "$filename"_"$time"
	last="$filename"
done

Note that both of these (and the code suggested by Corona688) assume that list is the name of a file containing one line for each .xlsx file in your share point directory and that that line contains only that file's complete filename.
This User Gave Thanks to Don Cragun For This Post:
# 4  
Old 08-02-2017
Quote:
Originally Posted by Don Cragun
Since the year comes after the month and day in the timestamps in these filenames, the sort needs to be a little more complicated (and assuming that the filename prefix does not contains any other _s):
Code:
NAME=$(sort -r -t_ -k2.4,2.8 -k2.1,2.4 list | head -n 1)

assuming that there is only one filename before the underscore in your list. If there are multiple filename prefixes in your list, you'll need a loop something like:
Code:
last=
sort -t_ -k1,1 -k2.4,2.8r -k2.1,2.4r list | while IFS=_ read -r filename time
do    if [ "$last" = "$filename" ]
    then    continue
    fi
    curl other_parameters "$filename"_"$time"
    last="$filename"
done

Note that both of these (and the code suggested by Corona688) assume that list is the name of a file containing one line for each .xlsx file in your share point directory and that that line contains only that file's complete filename.
Thanks for the details . But when try with this it is giving error
" sort: Cannot open list"

Please help me with this issue.
# 5  
Old 08-02-2017
Replace "list" with the name of the file containing
Quote:
Originally Posted by puttaiah

the list of files with the timestamp.
that you have.

Last edited by RudiC; 08-02-2017 at 01:51 PM..
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to download recursively a folder using /usr/bin/ftp and cshell?

Hi, friends, I am meet a ftp download problem when using cshell and /usr/bin/ftp command. I want to download recursively a folder dira from FTP server. dira ---dira1-----dira2------dira3-----dira4 |--file11 |--file21 |--file31 |--file41 |--file12 |--file22 |--file32 ... (1 Reply)
Discussion started by: weichanghe2000
1 Replies

2. Shell Programming and Scripting

Shell: uploading file from UNIX server to sharepoint server

Is it possible to upload a file from unix server to sharepoint server through shell or perl scripting. I have the sharepoint link where it needs to be uploaded. Could you please share your views on this ? (0 Replies)
Discussion started by: scriptscript
0 Replies

3. Shell Programming and Scripting

want to move set of file from one folder to another folder

Hi all, let me explain my requirments i am having 5 folder with different name for eg) abc , cdf , efd, rtg, ead each 5 folders contain 15 files i want to move 10 files to some other folder, remain 5 files should be there in the same folder. give me some suggestion on this. (6 Replies)
Discussion started by: natraj005
6 Replies

4. Shell Programming and Scripting

Wget, download file from site's folder.

Ok, this is quite weird. wget -r mysite.com/mylink/ should get all the files recursively from the 'mylink' folder. The problem is that wget saves an index.html file! When I open this index.html with my browser I realize that it shows all the files in the current folder (plus an option to move... (3 Replies)
Discussion started by: hakermania
3 Replies

5. Shell Programming and Scripting

copy file to sharepoint

Could you please guide me on copying/deleting file from unix/solaris machine to sharepoint (windows) . (0 Replies)
Discussion started by: ajay.bisht
0 Replies

6. Shell Programming and Scripting

load file to sharepoint using unix

I have a requirement to upload a file to the MS sharepoint site using unix or any other programming language. Does sharepoint support ftp? I heard it doesn't ...is it true...if yes is it different from what regular ftp we use....is there any other programming way out to upload the file to... (1 Reply)
Discussion started by: RubinPat
1 Replies

7. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

8. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

9. UNIX for Dummies Questions & Answers

May download a folder using wget command!

Hi All, I think wget command would not download any directories. But please confirm it. If it downloads directories, please let me know how to do it. Thank you. (1 Reply)
Discussion started by: ThrdF
1 Replies

10. UNIX for Dummies Questions & Answers

how to download a folder

Hi all, If I want to download a whole directory from website on the internet, how can I do that ??? From GUI side and the prompt site???? Please help Thanks (1 Reply)
Discussion started by: lapnguyen
1 Replies
Login or Register to Ask a Question