Is there a solution to choose how my file is renamed if a file with the same name already exist? - sharepoint

In SharePoint online when my flow moves the file (PDF, ZIP...) named "U000" in a folder where is a file with the same name it renames the file in "U0001".
How can I customize this to be renamed like "U000-Rev.1" or "U000_copy(1)" instead of "U0001"?
I know this is the default SharePoint behavior and there is no option for renaming format but maybe I can change or add a code in "definition.json" file from exported ZIP flow (or somewhere else).
(I'm not a software developer so any answer/idea is welcomed.)
Thank you!

Add an if statement to check the file name you just uploaded. If it contains (1) at the end of the name then rename the file. This is probably the least convoluted fast approach but it's not 100% robust.
You can add more logic or change the approach to make it fully robust but you can look into that after you've got something working imo, baby steps.

Related

Copy Data activity in ADF creates strange temporary filenames

I am using a Copy Data activity to upload the contents of a database table as .csv files to an SFTP server using a self-hosted Integration Runtime.
The "owners" of the FTP site have pointed out that they are seeing "strange" filenames, i.e. a guid appended to the designated filename. When I look at the uploaded files, however, that suffix is gone.
It appears therefore that the Copy Data activity
(a) creates the file with a guid in the name,
(b) streams the content into the file, and
(c) renames the file at the end.
Can somebody confirm or deny this? Has anybody else seen this behaviour?
(The problem with this is obviously that step (a) triggers some processing in another system, which is a problem for me).
Any help is greatly appreciated.
Thank, Martin
The behavior you are describing indicates you have "Upload with temp file" checked (which I believe is the default) in your SFTP source:
You may uncheck this box if you don't want it or if the server doesn't support it.

Shortcut with environment variable

I'm at work, with a folder in which we create a daily excel sheet to manage our clients. For the sake of understanding let's imagine this files is in a folder called OCTOBER and they are named MD01, MD02, MD03... based on the day we are.
I was trying to setup a shortcut on my desktop that will call the correct file every time so I don't have to go trough the file structure to access it. Something like this:
"....\OCTOBER\MD%DAY%.xls"
But the moment I try to setup the path this way I get an error say this is not a valid path. Well, either I am missing something here or what? Can't this be done?
A typical method is to create a link to a master file in the folder (say master.xlsm) The master spreadsheet would automatically:
determine the date
determine the appropriate file to open
open the file (say MD10.xls)
close itself
Alternatively you could create a little vbscript or powershell script or .bat file to do the same thing.

Retrieve contents of a ZIP file on SharePoint without downloading it

I have written a bit of automated code that checks a SharePoint site and looks for a ZIP file (lets call it doc.zip). If doc.zip is found, it downloads it, and then checks for a file (say target.docx). doc.zip is about 300MB, and so I want to only download where necessary.
What I would like to know is that given SharePoint has some ZIP search capability, is it possible to write code using CSOM (c#) to find doc.zip, and then run some code to retrieve the contents of doc.zip without downloading it.
Just to re-iterate, I am comfortable with searching for files in a folder on SP, downloading the file, and unpacking zip entries. What I need is to retrieve a ZIP files content on SP without downloading it.
E.g. is there a SP command:
cxt.Load(SomeZipFileQuery);
cxt.ExecuteQuery();
Thanks in advance.
This capability is not available. I do like the idea. Having the ability to "parse" zip files on the server side and then download the relevant bits would be ideal. Perhaps raise this on uservoice to see if others also find this us https://sharepoint.uservoice.com
Ok, I have proven yet again that stubbornness will prevail.
I have figured out that if I use the /_api/search?query='myfile.zip' web REST API to search for my file, this search will also match ZIP files that contain the file I need. And it works perfectly.
Of course there is added (pain) of parsing an XML response, but it works very nicely for my code example.
At least if someone is looking for this solution here it is. I wont bore anyone with code, as the /_api/search has probably been done to death already on other threads.

Batch file for inserting macro's

I am trying to create a batch file as icon on desktop, that would open a specific excel file, create a macro in it and copy code from a specific txt file into it.
The reason i need this, is that the file is located on a server and the ending .xlm cannot be cahanged (should not) so i cannot save it as a macro enabled file (to store a macro in it )
Could annyone with better understanding please explain to me how to create the said code ?
Thanks in advance!
In theory it's possible by using the VBE object (https://msdn.microsoft.com/en-us/library/aa443984%28v=vs.60%29.aspx). But that's not activated by default so you can not ensure that each user is able to do that.
Better find other solutions for that problem. Can you upload .XLSB for example? Or do you have another kind of server available - for example a database server - you can use for storing the file? We use this method here for deploying our updates on AddIns and report templates for example.

Excel Sheet Project References

I am programatically opening excel workbooks under a folder tree to check for some project references using the following code -
workbook = app.Workbooks.Open(fileName,false,true,Missing,Missing,.....);
foreach(Reference r in workbook.VBProject.References)
{
//check for a specific reference here
}
This works fine but my folder structure is very deep and I have over 20,000 spreadsheets stored in them. Sometimes depending on the size of the excel file, the call to Workbooks.Open() takes a long time (over 5 minutes per call on some files). Is there a faster more efficient way to do this?
Thanks for the help
It seems like whenever you have to hit the Excel object model, you're going to take a performance hit. I agree with the previous poster, that if you want to speed up performance, you'll need to read the Excel files directly.
As a side note, since Excel 2007 files (*.xlsm, *.xltm) are essentially *.zip files, you would need to find and access the vbaProject.bin file directly. A quick look points to the path as (I changed the extension so I could browse the file):
..\Book1.zip\xl\vbaProject.bin
Obviously you could dig through that bin file manually and find particular references (as suggested by the previous poster), but if you're looking to loop through all of the references in a project, you'll need to use the API calls IStream/IStorage. There's a great article about reverse engineering the Office BIN files here: http://www.codeproject.com/KB/cs/office2007bin.aspx. To access references in vbaProject.bin, look for the section titled "Reading or updating vbaProject.bin parts". There is also a sample C# code project that demonstrates how to read an OLE container. I just took a peak at the code sample, so I can't attest to it's effectiveness, but it certainly seems in order.
Hope that helps!
I don't think you can increase the Workbooks.Open performance. However if your main intention is just to check if a particular reference is used by the Spreadsheet or not, then consider opening the Excel file in binary mode and searching for the dll string.(The path of the dll providing the functionality, which can be seen in the Location part of the References Window).
This would be very crude way, but if the Workbook.Open performance is really a bottleneck then you can definitely give it a try.

Resources