Skip to main content
Participant
March 1, 2023
Open for Voting

P: Importing photos from FTP server & using the selected preset to edit the photo at the same time

  • March 1, 2023
  • 0 replies
  • 584 views

Dear Adobe Community,

I would like to request a plugin that automatically imports photos from an FTP server into Lightroom CC. The plugin should allow the user to specify the FTP server name, username, password, and port. Additionally, it should allow the user to select a destination folder on the server, as well as specify the name of the album in Lightroom to which the imported photos should be added.

Here is a sample code that can be used as a starting point:

 

const ftp = require('basic-ftp');
const LrCatalog = app.activeCatalog; // Get the active Lightroom catalog object

// FTP login credentials
const server = 'ftp.example.com';
const user = 'username';
const password = 'password';
const port = 21;

// Import photos from FTP server to Lightroom
async function importFromFTP() {
const client = new ftp.Client();
client.ftp.verbose = true;

try {
// Connect to FTP server
await client.access({
host: server,
user: user,
password: password,
port: port,
});

// Get list of files on the FTP server
const files = await client.list('/');

// Import each file from the FTP server to Lightroom
for (const file of files) {
if (file.type === 1) {
// Ignore directories
continue;
}

// Check if file is already imported into Lightroom
if (!isFileAlreadyImported(file.name)) {
// Import file into Lightroom
await importFileToLightroom(file.name);
}
}
} catch (err) {
console.log(err);
}

// Refresh file list every minute
setTimeout(importFromFTP, 60000);
}

// Check if file is already imported into Lightroom
function isFileAlreadyImported(filename) {
// Code to check if file with "filename" already exists in Lightroom's import folder
// Returns true if file already exists, false otherwise
}

// Import file into Lightroom
async function importFileToLightroom(filename) {
// Code to import file with "filename" into Lightroom
// Adds file to specified destination folder on FTP server
// Adds file to specified album in Lightroom
const destFolder = LrCatalog.getTargetFolderForLibraryFolderName('My Photos'); // Change to the desired destination folder name
const albumName = 'Imported Photos'; // Change to the desired album name
const presetName = 'My Preset'; // Change to the desired preset name

// Import the file into Lightroom
const importedPhotos = await LrCatalog.importFilesFrom(
[filename],
destFolder,
albumName,
false,
null
);

// Apply the preset to the imported photos
if (importedPhotos.length > 0) {
const preset = LrCatalog.getDevelopPresetWithName(presetName);
if (preset) {
for (const photo of importedPhotos) {
const developSettings = photo.getDevelopSettings();
developSettings.applyPreset(preset);
await photo.saveMetadata();
}
} else {
console.log(`Could not find preset "${presetName}".`);
}
}
}

// Run the importFromFTP function
importFromFTP();

 

This code assumes that you have created a Develop preset in Lightroom named "My Preset" that you want to apply to the imported photos. You can change the name of the preset by modifying the presetName variable.

I hope this helps!

 

Thank you for considering my request. I believe that such a plugin would be of great benefit to many photographers who work with FTP servers to store and share their photos. Sure, I'll be happy to help you achieve the ability to quickly share your street photography with others. My knowledge doesn't help me finish this

Best regards, Mariusz Sęk