Script to cause duplicate active script with name change and importrange function + new folder - directory

I am new to stackoverflow and i am not a programmer but i am developing my skills in google sheets and scripts ( but still a newbie).
Right now i am trying to do this:
Duplicating active spreadsheet to totally new file but with use of importrange function so the new file can be automaticly updated when i change data in original file.
rename the new file using particular cell in original file.
Create new folder in particular master folder where this new file will be placed and rename this folder using the same particular cell as above.
i am able to rename or duplicate the file but i don't know how to implicate the importrange function and totally dumb with folder creation in master folder. Any hints will be gold for me ;)
I have tried renaming and duplicating the file, i honestly don't know how to implement importrange ( the function have to take file ID automaticly as i will be copying the template of Master file for every event i make.
For now i have managed to copy the file and rename it with particular cell with this function:
function createCopy() {
var myValue = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("H1").getValue();
var destinationFolder = DriveApp.getFolderById("MASTER FOLDER");
DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).makeCopy(myValue,destinationFolder);
}

Related

Smartsheet api workspace sheet set

Thi is my first question.
I'm developing an exportation from our SQL based ERP to smartsheep.
We are developing in .NET (VB).
I'm creating / uploading sheet and creating data in row without problems.
My actual and almost last trouble is to be able to set a specified workspace...
Example.
I Upload a template XLSX file to smartsheet. I populate it with all the data i need to put inside, than (and here we are) i would like to set to the uploaded Sheet a specific workspace...
I'm using nuget smartsheet-csharp-sdk Version 2.126.0
Thank you for any reply.
This is more or less my code:
Dim smartsheet As SmartsheetClient = New SmartsheetBuilder().Build()
Dim sheet As Sheet = smartsheet.SheetResources.ImportXlsSheet(Dim XLSFILENAME as string, Nothing, 0, Nothing)
Than i have my build / upload rows code...
but no idea on how to set the workspace....
With the import ImportXlsSheet you can't set a destination, the sheet will be created at the root (home) or smartsheet.
You've to create the sheet, and by the response you should have access to the sheetId created.
With a second call to the API, move the sheet to the specific workspace. see also : https://smartsheet-platform.github.io/api-docs/?csharp#move-sheet

wordpress media upload to rename files appropriately if file exists

I'm creating a plugin in wordpress that uses the wp media uploader to upload files to the site. Problem is that if a file exists with the same name, the name of the file being currently uploaded is appended with a number at the end.
This is a problem if I upload file001.pdf and then the next file is renamed to file0012.pdf instead of file001-2.pdf
It's a problem because then the user may think that is file 12 and not version 2 of file 1.
How can i change that so if there's already a file in the system with the same name, the file being uploaded gets the right rename?
EDIT
So I found out there's a function in wp-includes/functions.php called wp_unique_filename which will check for unique file names and increment until the name is unique. I just need to find a way now to customize that function on the plugin directory.
WordPress provides one hook wp_handle_upload_prefilter as below
function handle_uploadedimage($arr) {
$random_number = md5(rand(10000,99999));
$ext = pathinfo($arr['name'], PATHINFO_EXTENSION);
$arr['name'] = $random_number .'.'.$ext;
return $arr;
}
add_filter('wp_handle_upload_prefilter', 'handle_uploadedimage', 1, 1);

ASP.NET creating resources at runtime

I'm developing an ASP.NET webapp that has a multilanguage feature allowing the webmaster to create new languages at runtime.
The approach that I was thinking is the following:
The user selects one available (not created) language.
When the user confirms, the application automatically copies a set of existing resources, replacing the filename with the new culture. For example: default.aspx.en-us.resx to default.aspx.es-ar.resx.
The user edits the recently created resources.
Currently I'm having troubles with step number 2. I've achieved to copy the resources, but then these new resources are ignored. I think that this happens because the new resources are not included in the running assembly, and therefore are being ignored.
When I test the following code in my local project, I would have to manually add the new resources to the solution and then recompile to make it work.
Does anyone know how to make this work?
This is the code of the mentioned copy.
string _dir = path_ + "App_LocalResources\\\\";
DirectoryInfo _dirInfo = new DirectoryInfo(_dir);
foreach (FileInfo _file in _dirInfo.GetFiles("*en-us.resx")) {
_file.CopyTo(_dir + _file.Name.Replace("en-us", idioma_.Cultura));
}
string _dir2 = path_ + "App_GlobalResources\\\\";
_dirInfo = new DirectoryInfo(_dir2);
foreach (FileInfo _file in _dirInfo.GetFiles("*en-us.resx")) {
_file.CopyTo(_dir2 + _file.Name.Replace("en-us", idioma_.Cultura));
}
Thank you very much.
Creating or editing Resource files is not possible the same way as reading data.
In order to create or edit a resource file, you should do it the same way you create or edit XML files because resource files have with a specific structured XML elements.
Maybe this article will help you...

InDesign CS5 Script: How can you display a directory?

I have a script that:
creates a new folder
scans an InDesign document for images
formats the images and copies them to the new folder
When the script is done doing all of this I want it to bring to focus the new folder directory (in Windows).
As of now I am displaying the folder-path in an alert window, but I would rather it open the directory (if it isn't already) so the user can see the new files.
I wish I could just call one of these:
myNewFolder.bringToFront() : works only on program focus, i.e. -- BridgeTalk.bringToFront("photoshop")
myNewFolder.open() : seems to apply only to file I/O operations
myNewFolder.show() : seems to apply only to the Window object
...but none of these work.
EDIT: new ActiveXObject("Scripting.FileSystemObject") does not work either...
You have to use the execute method.
myFolder.execute();

How can I associate many existing files with drupal filefield?

I have many mp3 files stored on my server already from a static website, and we're now moving to drupal. I'm going to create a node for each audio file, but I don't want to have to upload each file again. I'd rather copy the files into the drupal files directory where I want them, and then associate the nodes with the appropriate file.
Any ideas on how to accomplish that?
Thanks!
I am not sure if I am going to propose a different approach or if I am about to tell with different words what you already meant with your original question, but as you want the nodes to be the files, I would rather generate the nodes starting from the files, rather than associating existing nodes with existing files.
In generic terms I would do it programmatically: for each existing files in your import directory I would build the $node object and then invoke node_save($node) to store it in Drupal.
Of course in building the $node object you will need to invoke the API function of the module you are using to manage the files. Here's some sample code I wrote to do a similar task. In this scenario I was attaching a product sheet to a product (a node with additional fields), so...
field_sheet was the CCK field for the product sheet in the product node
product was the node type
$sheet_file was the complete reference (path + filename) to the product sheet file.
So the example:
// Load the CCK field
$field = content_fields('field_sheet', 'product');
// Load the appropriate validators
$validators = array_merge(filefield_widget_upload_validators($field));
// Where do we store the files?
$files_path = filefield_widget_file_path($field);
// Create the file object
$file = field_file_save_file($sheet_file, $validators, $files_path);
// Apply the file to the field, this sets the first file only, could be looped
// if there were more files
$node->field_scheda = array(0 => $file);
// The file has been copied in the appropriate directory, so it can be
// removed from the import directory
unlink($sheet_file);
BTW: if you use a library to read MP3 metadata, you could set $node->title and other attributes in a sensible way.
Hope this helps!
The file_import module doesn't do exactly what you want (it creates node attachments instead of nodes), but it would be relatively simple to use that module as guidance along with the Drapal API to do what you want.

Resources